diff options
author | NerdyPepper <[email protected]> | 2019-07-09 18:26:27 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-07-09 18:26:27 +0100 |
commit | ff37975452d4cbc8a3f117baa9444f3fd023bd66 (patch) | |
tree | 1cc79bf6ed097621b8fdf52b6323f0968614e639 /src/cwd.rs | |
parent | f2ac2b494b4f5ad87ca83fb256305757b672d7dd (diff) |
handle edge cases
Diffstat (limited to 'src/cwd.rs')
-rw-r--r-- | src/cwd.rs | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -8,7 +8,11 @@ pub fn cwd() -> colored::ColoredString { | |||
8 | let tilde_expand = env::var("EXPAND_TILDE").unwrap_or("0".into()); | 8 | let tilde_expand = env::var("EXPAND_TILDE").unwrap_or("0".into()); |
9 | 9 | ||
10 | match tilde_expand.as_ref() { | 10 | match tilde_expand.as_ref() { |
11 | "0" => path = path.replace(&home[..], "~"), | 11 | "0" => { |
12 | if (&path[..]).starts_with(&home[..]) && home.len() > 0 { | ||
13 | path = path.replacen(&home[..], "~", 1); | ||
14 | } | ||
15 | } | ||
12 | _ => {} | 16 | _ => {} |
13 | }; | 17 | }; |
14 | 18 | ||