aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-08-06 17:07:32 +0100
committerNerdyPepper <[email protected]>2019-08-06 17:07:32 +0100
commit53fce2c35efc52e36e587b79afdceb7e68580718 (patch)
tree4c9d8c8a09a0f57fa0289422c7aa40e17a75115e /src
parentbb78ea7e50b278f00cb4f964ca9de5d12124c46f (diff)
make changes as @shdown suggested
Diffstat (limited to 'src')
-rw-r--r--src/cwd.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cwd.rs b/src/cwd.rs
index 157858c..c8af68e 100644
--- a/src/cwd.rs
+++ b/src/cwd.rs
@@ -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}