diff options
author | NerdyPepper <[email protected]> | 2019-05-19 13:54:52 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-05-19 13:54:52 +0100 |
commit | 3fad890e7480a230152da8a799a5c6068f1a4963 (patch) | |
tree | 4d10f2d527525ac1c7b0dc10bbd044b7693f616c /src/main.rs | |
parent | e39bc3110eeda9aa07f8af3c537486edf885a51a (diff) |
init
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..6ddfe0f --- /dev/null +++ b/src/main.rs | |||
@@ -0,0 +1,31 @@ | |||
1 | use std::env; | ||
2 | use tico::tico; | ||
3 | |||
4 | fn main() { | ||
5 | println!("{}", cwd()); | ||
6 | println!("{}", prompt_char()); | ||
7 | } | ||
8 | |||
9 | fn cwd() -> String { | ||
10 | let path = env::var("PWD").unwrap(); | ||
11 | let short_or_not = env::var("SHORTEN_CWD").unwrap_or("1".into()); | ||
12 | |||
13 | match short_or_not.as_ref() { | ||
14 | "0" => path, | ||
15 | _ => tico(&path[..]) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | fn prompt_char() -> String { | ||
20 | let user_char = env::var("PROMPT_CHAR").unwrap_or("$ ".into()); | ||
21 | let root_char = env::var("PROMPT_CHAR_ROOT").unwrap_or("# ".into()); | ||
22 | |||
23 | let euid = unsafe { libc::geteuid() }; | ||
24 | match euid { | ||
25 | 0 => return root_char, | ||
26 | _ => return user_char | ||
27 | } | ||
28 | } | ||
29 | |||
30 | fn vcs() -> String { | ||
31 | } | ||