diff options
author | NerdyPepper <[email protected]> | 2019-08-06 17:07:32 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-08-06 17:07:32 +0100 |
commit | 53fce2c35efc52e36e587b79afdceb7e68580718 (patch) | |
tree | 4c9d8c8a09a0f57fa0289422c7aa40e17a75115e /src/cwd.rs | |
parent | bb78ea7e50b278f00cb4f964ca9de5d12124c46f (diff) |
make changes as @shdown suggested
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 | } |