diff options
Diffstat (limited to 'src/cwd.rs')
-rw-r--r-- | src/cwd.rs | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -1,11 +1,22 @@ | |||
1 | use colored::*; | ||
1 | use std::env; | 2 | use std::env; |
2 | use tico::tico; | 3 | use tico::tico; |
3 | use colored::*; | ||
4 | 4 | ||
5 | pub fn cwd() -> Option<colored::ColoredString> { | 5 | pub fn cwd() -> Option<colored::ColoredString> { |
6 | let path_env = env::current_dir().ok()?; | 6 | let path_env = env::current_dir().ok()?; |
7 | let mut path = format!("{}", path_env.display()); | 7 | let mut path = format!("{}", path_env.display()); |
8 | let home = env::var("HOME").unwrap(); | 8 | let home = env::var("HOME").unwrap(); |
9 | |||
10 | let hide_home = env::var("HIDE_HOME_CWD").unwrap_or("0".into()); | ||
11 | match hide_home.as_ref() { | ||
12 | "0" => {} | ||
13 | _ => { | ||
14 | if &path == &home { | ||
15 | return Some(colored::ColoredString::from("")); | ||
16 | } | ||
17 | } | ||
18 | } | ||
19 | |||
9 | let tilde_expand = env::var("EXPAND_TILDE").unwrap_or("0".into()); | 20 | let tilde_expand = env::var("EXPAND_TILDE").unwrap_or("0".into()); |
10 | 21 | ||
11 | match tilde_expand.as_ref() { | 22 | match tilde_expand.as_ref() { |
@@ -23,7 +34,6 @@ pub fn cwd() -> Option<colored::ColoredString> { | |||
23 | let cwd_color = env::var("CWD_COLOR").unwrap_or("white".into()); | 34 | let cwd_color = env::var("CWD_COLOR").unwrap_or("white".into()); |
24 | match cwd_shorten.as_ref() { | 35 | match cwd_shorten.as_ref() { |
25 | "0" => return Some(path.color(cwd_color)), | 36 | "0" => return Some(path.color(cwd_color)), |
26 | _ => return Some(tico(&path).color(cwd_color)) | 37 | _ => return Some(tico(&path).color(cwd_color)), |
27 | } | 38 | } |
28 | |||
29 | } | 39 | } |