diff options
author | Jesse Luehrs <doy@tozt.net> | 2018-05-22 01:53:04 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2018-05-22 01:53:04 -0400 |
commit | b0c51f55450c317e8ec4bd5daecaa58539334cb0 (patch) | |
tree | ef3921e9a5b67bc47fad5dd5f73f11d393e5c4e1 | |
parent | de3bac4ab1950549d298844846d04ab2f54049db (diff) | |
download | fancy-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.rs | 10 |
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> { |