aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-05-22 01:53:04 -0400
committerJesse Luehrs <doy@tozt.net>2018-05-22 01:53:04 -0400
commitb0c51f55450c317e8ec4bd5daecaa58539334cb0 (patch)
treeef3921e9a5b67bc47fad5dd5f73f11d393e5c4e1
parentde3bac4ab1950549d298844846d04ab2f54049db (diff)
downloadfancy-prompt-b0c51f55450c317e8ec4bd5daecaa58539334cb0.tar.gz
fancy-prompt-b0c51f55450c317e8ec4bd5daecaa58539334cb0.zip
strip off hostname part following the '.'
osx puts a bunch of worthless (and constantly changing for no reason) things in the hostname, which just is more confusing than anything else
-rw-r--r--src/data.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/data.rs b/src/data.rs
index be6ea9f..e1a77a0 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -63,7 +63,15 @@ pub fn collect(opts: args::CommandLineOptions) -> PromptData {
}
fn hostname() -> Option<String> {
- hostname::get_hostname()
+ if let Some(mut name) = hostname::get_hostname() {
+ if let Some(idx) = name.find('.') {
+ name.truncate(idx);
+ }
+ Some(name)
+ }
+ else {
+ None
+ }
}
fn terminal_cols() -> Option<usize> {