From f982aa673701bd5084a228ce9caee6941e3d86f1 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Mon, 20 May 2019 18:18:12 +0530 Subject: grand refactor --- src/prompt_char.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/prompt_char.rs (limited to 'src/prompt_char.rs') 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 @@ +use std::env; +use colored::*; + +pub fn prompt_char() -> colored::ColoredString { + let user_char = env::var("PROMPT_CHAR").unwrap_or("$ ".into()); + let root_char = env::var("PROMPT_CHAR_ROOT").unwrap_or("# ".into()); + + let euid = unsafe { libc::geteuid() }; + match euid { + 0 => return root_char.red(), + _ => return user_char.green() + } +} + -- cgit v1.2.3