diff options
Diffstat (limited to 'src/cwd.rs')
-rw-r--r-- | src/cwd.rs | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -10,8 +10,10 @@ pub fn cwd() -> Option<colored::ColoredString> { | |||
10 | 10 | ||
11 | match tilde_expand.as_ref() { | 11 | match tilde_expand.as_ref() { |
12 | "0" => { | 12 | "0" => { |
13 | if (&path[..]).starts_with(&home[..]) && home.len() > 0 { | 13 | let home_dir = &home.clone(); |
14 | path = path.replacen(&home[..], "~", 1); | 14 | let home_dir_ext = format!("{}{}", home_dir, "/"); |
15 | if (&path == home_dir) || *(&path.starts_with(&home_dir_ext)) { | ||
16 | path = path.replacen(&home_dir[..], "~", 1); | ||
15 | } | 17 | } |
16 | } | 18 | } |
17 | _ => {} | 19 | _ => {} |
@@ -21,7 +23,7 @@ pub fn cwd() -> Option<colored::ColoredString> { | |||
21 | let cwd_color = env::var("CWD_COLOR").unwrap_or("white".into()); | 23 | let cwd_color = env::var("CWD_COLOR").unwrap_or("white".into()); |
22 | match cwd_shorten.as_ref() { | 24 | match cwd_shorten.as_ref() { |
23 | "0" => return Some(path.color(cwd_color)), | 25 | "0" => return Some(path.color(cwd_color)), |
24 | _ => return Some(tico(&path[..]).color(cwd_color)) | 26 | _ => return Some(tico(&path).color(cwd_color)) |
25 | } | 27 | } |
26 | 28 | ||
27 | } | 29 | } |