diff options
Diffstat (limited to 'src/prompt_char.rs')
-rw-r--r-- | src/prompt_char.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/prompt_char.rs b/src/prompt_char.rs new file mode 100644 index 0000000..1df4c5d --- /dev/null +++ b/src/prompt_char.rs | |||
@@ -0,0 +1,14 @@ | |||
1 | use std::env; | ||
2 | use colored::*; | ||
3 | |||
4 | pub fn prompt_char() -> colored::ColoredString { | ||
5 | let user_char = env::var("PROMPT_CHAR").unwrap_or("$ ".into()); | ||
6 | let root_char = env::var("PROMPT_CHAR_ROOT").unwrap_or("# ".into()); | ||
7 | |||
8 | let euid = unsafe { libc::geteuid() }; | ||
9 | match euid { | ||
10 | 0 => return root_char.red(), | ||
11 | _ => return user_char.green() | ||
12 | } | ||
13 | } | ||
14 | |||