diff options
author | NerdyPepper <[email protected]> | 2019-05-20 13:48:12 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-05-20 13:48:12 +0100 |
commit | f982aa673701bd5084a228ce9caee6941e3d86f1 (patch) | |
tree | daf943b3bbc686e0818dfb697c6ad145a95e2f3f /src/cwd.rs | |
parent | af5b620f472ceefc2408f59fdf30b85e92390f7f (diff) |
grand refactor
Diffstat (limited to 'src/cwd.rs')
-rw-r--r-- | src/cwd.rs | 22 |
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 @@ | |||
1 | use std::env; | ||
2 | use tico::tico; | ||
3 | use colored::*; | ||
4 | |||
5 | pub 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 | } | ||