aboutsummaryrefslogtreecommitdiff
path: root/src/prompt_char.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/prompt_char.rs')
-rw-r--r--src/prompt_char.rs14
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 @@
1use std::env;
2use colored::*;
3
4pub 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