aboutsummaryrefslogtreecommitdiff
path: root/src/cwd.rs
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-05-20 13:48:12 +0100
committerNerdyPepper <[email protected]>2019-05-20 13:48:12 +0100
commitf982aa673701bd5084a228ce9caee6941e3d86f1 (patch)
treedaf943b3bbc686e0818dfb697c6ad145a95e2f3f /src/cwd.rs
parentaf5b620f472ceefc2408f59fdf30b85e92390f7f (diff)
grand refactor
Diffstat (limited to 'src/cwd.rs')
-rw-r--r--src/cwd.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cwd.rs b/src/cwd.rs
new file mode 100644
index 0000000..8f1f86a
--- /dev/null
+++ b/src/cwd.rs
@@ -0,0 +1,22 @@
1use std::env;
2use tico::tico;
3use colored::*;
4
5pub fn cwd() -> colored::ColoredString {
6 let mut path = env::var("PWD").unwrap();
7 let home = env::var("HOME").unwrap();
8 let tilde_expand = env::var("EXPAND_TILDE").unwrap_or("0".into());
9
10 match tilde_expand.as_ref() {
11 "0" => {},
12 _ => path = path.replace(&home[..], "~")
13 };
14
15 let cwd_shorten = env::var("SHORTEN_CWD").unwrap_or("1".into());
16 let cwd_color = env::var("CWD_COLOR").unwrap_or("white".into());
17 match cwd_shorten.as_ref() {
18 "0" => return path.color(cwd_color),
19 _ => return tico(&path[..]).color(cwd_color)
20 }
21
22}