aboutsummaryrefslogtreecommitdiff
path: root/src/cwd.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cwd.rs')
-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}