blob: 95b6659f379b1d21f3961a34f1eaa950388ac791 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
use std::env;
use tico::tico;
use colored::*;
pub fn cwd() -> colored::ColoredString {
let mut path = format!("{}", env::current_dir().unwrap_or("".into()).display());
let home = env::var("HOME").unwrap();
let tilde_expand = env::var("EXPAND_TILDE").unwrap_or("0".into());
match tilde_expand.as_ref() {
"0" => {
if (&path[..]).starts_with(&home[..]) && home.len() > 0 {
path = path.replacen(&home[..], "~", 1);
}
}
_ => {}
};
let cwd_shorten = env::var("SHORTEN_CWD").unwrap_or("1".into());
let cwd_color = env::var("CWD_COLOR").unwrap_or("white".into());
match cwd_shorten.as_ref() {
"0" => return path.color(cwd_color),
_ => return tico(&path[..]).color(cwd_color)
}
}
|