aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--readme.md3
-rw-r--r--src/cwd.rs16
-rw-r--r--src/main.rs4
3 files changed, 18 insertions, 5 deletions
diff --git a/readme.md b/readme.md
index 2524932..c0629cd 100644
--- a/readme.md
+++ b/readme.md
@@ -94,6 +94,9 @@ export CWD_COLOR="white"
94# if EXPAND_TILDE is set to 0, `/home/nerdypepper` is shortened to `~` 94# if EXPAND_TILDE is set to 0, `/home/nerdypepper` is shortened to `~`
95export EXPAND_TILDE=0 95export EXPAND_TILDE=0
96 96
97# if HIDE_HOME_CWD is set to 1, path is hidden when in $HOME
98export HIDE_HOME_CWD=1
99
97# there are three possible states for a git repo 100# there are three possible states for a git repo
98# - unstaged (working tree has been modified) 101# - unstaged (working tree has been modified)
99# - staged (staging area has been modified) 102# - staged (staging area has been modified)
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}
diff --git a/src/main.rs b/src/main.rs
index 6ccca7b..aa19abd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -40,7 +40,7 @@ fn pista(zsh: bool) -> String {
40 }; 40 };
41 let (branch, status) = match env::var("DISABLE_VCS").unwrap_or("0".into()).as_ref() { 41 let (branch, status) = match env::var("DISABLE_VCS").unwrap_or("0".into()).as_ref() {
42 "0" => vcs::vcs_status().unwrap_or(("".into(), "".into())), 42 "0" => vcs::vcs_status().unwrap_or(("".into(), "".into())),
43 _ => ("".into(), "".into()) 43 _ => ("".into(), "".into()),
44 }; 44 };
45 let venv = venv::get_name(); 45 let venv = venv::get_name();
46 let prompt_char = prompt_char::get_char(); 46 let prompt_char = prompt_char::get_char();
@@ -75,7 +75,7 @@ fn pista_minimal(zsh: bool) -> String {
75 let mut vcs_component = String::new(); 75 let mut vcs_component = String::new();
76 if let Some((branch, status)) = vcs_tuple { 76 if let Some((branch, status)) = vcs_tuple {
77 vcs_component = format!(" [{} {}] ", branch, status); 77 vcs_component = format!(" [{} {}] ", branch, status);
78 } else { 78 } else if cwd.len() > 0 {
79 vcs_component.push(' '); 79 vcs_component.push(' ');
80 } 80 }
81 let venv = venv::get_name(); 81 let venv = venv::get_name();