aboutsummaryrefslogtreecommitdiff
path: root/src/cwd.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cwd.rs')
-rw-r--r--src/cwd.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/cwd.rs b/src/cwd.rs
index c8af68e..3cc4a22 100644
--- a/src/cwd.rs
+++ b/src/cwd.rs
@@ -1,11 +1,22 @@
1use colored::*;
1use std::env; 2use std::env;
2use tico::tico; 3use tico::tico;
3use colored::*;
4 4
5pub fn cwd() -> Option<colored::ColoredString> { 5pub 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}