From 7bc593296e9a5ed693a30c92c25653d4a6cfcb54 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Mon, 20 May 2019 19:10:10 +0530 Subject: add config opts for prompt chars --- src/prompt_char.rs | 12 +++++++----- src/vcs.rs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/prompt_char.rs b/src/prompt_char.rs index 1df4c5d..a95681e 100644 --- a/src/prompt_char.rs +++ b/src/prompt_char.rs @@ -1,14 +1,16 @@ 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()); +pub fn get_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 user_char_color = env::var("PROMPT_CHAR_COLOR").unwrap_or("green ".into()); + let root_char_color = env::var("PROMPT_CHAR_ROOT_COLOR").unwrap_or("red".into()); let euid = unsafe { libc::geteuid() }; match euid { - 0 => return root_char.red(), - _ => return user_char.green() + 0 => return root_char.color(root_char_color), + _ => return user_char.color(user_char_color) } } diff --git a/src/vcs.rs b/src/vcs.rs index eddc83c..5bc194d 100644 --- a/src/vcs.rs +++ b/src/vcs.rs @@ -5,7 +5,7 @@ use colored::*; pub fn vcs_status() -> Option<(colored::ColoredString, colored::ColoredString)> { let current_dir = env::var("PWD").unwrap(); - + let mut repo: Option = None; let current_path = Path::new(¤t_dir[..]); for path in current_path.ancestors() { -- cgit v1.2.3