From f915e886be92e300494fee7f79e367fdcb26c79b Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Tue, 21 May 2019 08:28:16 +0530 Subject: add branch/commit color options --- src/vcs.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/vcs.rs b/src/vcs.rs index 26edf81..87c5517 100644 --- a/src/vcs.rs +++ b/src/vcs.rs @@ -27,12 +27,15 @@ pub fn vcs_status() -> Option<(colored::ColoredString, colored::ColoredString)> }; let mut branch; + let branch_color = env::var("BRANCH_COLOR").unwrap_or("bright black".into()); + let commit_color = env::var("COMMIT_COLOR").unwrap_or("bright black".into()); + if reference.is_branch() { - branch = format!("{}", reference.shorthand().unwrap()).bright_black(); + branch = format!("{}", reference.shorthand().unwrap()).color(branch_color); } else { let commit = reference.peel_to_commit().unwrap(); let id = commit.id(); - branch = format!("{:.6}", id).bright_black(); + branch = format!("{:.6}", id).color(commit_color); } let mut repo_stat = "".white(); @@ -58,7 +61,7 @@ pub fn vcs_status() -> Option<(colored::ColoredString, colored::ColoredString)> let stat_char = env::var("GIT_INDEX_MODIFIED").unwrap_or("±".into()); repo_stat = stat_char.color(&git_index_modified_color[..]); }, - // STATE: comitted (changes have been saved in the repo) + // STATE: committed (changes have been saved in the repo) _ => { let stat_char = env::var("GIT_CLEAN").unwrap_or("·".into()); repo_stat = stat_char.color(&git_clean_color[..]); -- cgit v1.2.3