aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-07-09 18:26:27 +0100
committerNerdyPepper <[email protected]>2019-07-09 18:26:27 +0100
commitff37975452d4cbc8a3f117baa9444f3fd023bd66 (patch)
tree1cc79bf6ed097621b8fdf52b6323f0968614e639
parentf2ac2b494b4f5ad87ca83fb256305757b672d7dd (diff)
handle edge cases
-rw-r--r--src/cwd.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cwd.rs b/src/cwd.rs
index 7672981..95b6659 100644
--- a/src/cwd.rs
+++ b/src/cwd.rs
@@ -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