diff options
author | NerdyPepper <[email protected]> | 2019-05-20 07:59:31 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-05-20 07:59:31 +0100 |
commit | 72954b99aee3371bb627d91894ca2d6d3326d99d (patch) | |
tree | 2cbde0972d62b4d89d1ca79f2089ec086d2f9f7d /src | |
parent | 590dcc87f46f90babd53f888a8d4c4f4f2fcc069 (diff) |
finish cwd fn
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 3e2b096..d5a0ce1 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -4,7 +4,7 @@ use git2::{ Repository, Status }; | |||
4 | use colored::*; | 4 | use colored::*; |
5 | 5 | ||
6 | fn main() { | 6 | fn main() { |
7 | // print!("{}", cwd()); | 7 | print!("{}", cwd()); |
8 | let (branch, status) = match vcs_status() { | 8 | let (branch, status) = match vcs_status() { |
9 | Some((x, y)) => { | 9 | Some((x, y)) => { |
10 | (x, y) | 10 | (x, y) |
@@ -15,12 +15,24 @@ fn main() { | |||
15 | print!("{} ", prompt_char()); | 15 | print!("{} ", prompt_char()); |
16 | } | 16 | } |
17 | 17 | ||
18 | // fn cwd() -> String { | 18 | fn cwd() -> colored::ColoredString { |
19 | // let path = env::var("PWD").unwrap(); | 19 | let mut path = env::var("PWD").unwrap(); |
20 | // let short_or_not = env::var("SHORTEN_CWD").unwrap_or("1".into()); | 20 | let home = env::var("HOME").unwrap(); |
21 | // | 21 | let tilde_expand = env::var("EXPAND_TILDE").unwrap_or("0".into()); |
22 | // _ => tico(&path[..]) | 22 | |
23 | // } | 23 | match tilde_expand.as_ref() { |
24 | "0" => {}, | ||
25 | _ => path = path.replace(&home[..], "~") | ||
26 | }; | ||
27 | |||
28 | let cwd_shorten = env::var("SHORTEN_CWD").unwrap_or("1".into()); | ||
29 | let cwd_color = env::var("CWD_COLOR").unwrap_or("white".into()); | ||
30 | match cwd_shorten.as_ref() { | ||
31 | "0" => return path.color(cwd_color), | ||
32 | _ => return tico(&path[..]).color(cwd_color) | ||
33 | } | ||
34 | |||
35 | } | ||
24 | 36 | ||
25 | fn prompt_char() -> colored::ColoredString { | 37 | fn prompt_char() -> colored::ColoredString { |
26 | let user_char = env::var("PROMPT_CHAR").unwrap_or("$ ".into()); | 38 | let user_char = env::var("PROMPT_CHAR").unwrap_or("$ ".into()); |