diff options
author | NerdyPepper <[email protected]> | 2019-05-20 13:48:12 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-05-20 13:48:12 +0100 |
commit | f982aa673701bd5084a228ce9caee6941e3d86f1 (patch) | |
tree | daf943b3bbc686e0818dfb697c6ad145a95e2f3f /src/prompt_char.rs | |
parent | af5b620f472ceefc2408f59fdf30b85e92390f7f (diff) |
grand refactor
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 | |||