[PATCH] Custom prompt colors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 41e9edae533306b4a50570e32dbbdd291a4a5fbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vanja=20Radovanovi=C4=87?= <elvanja@xxxxxxxxx>
Date: Sun, 9 Nov 2014 20:05:48 +0100
Subject: [PATCH] contrib/completion: custom git prompt colors

Allow git prompt colors to be customized.
Accept globally set colors, use defaults otherwise.

Note: requires /usr/lib/git-core/git-sh-promp to be
removed or commented out, so custom git-prompt.sh
can be used.
---
 contrib/completion/git-prompt.sh | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index c5473dc..ff5b04b 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -84,6 +84,10 @@
 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
 # the colored output of "git status -sb" and are available only when
 # using __git_ps1 for PROMPT_COMMAND or precmd.
+# Colors can be overridden; just set GIT_PS1_BAD_COLOR,
+# GIT_PS1_OK_COLOR and/or GIT_PS1_FLAGS_COLOR to the color of your choice.
+# Make sure you use appropriately escaped color codes, see
+# __git_ps1_colorize_gitstring function for details/defaults.

 # check whether printf supports -v
 __git_printf_supports_v=
@@ -240,9 +244,21 @@ __git_ps1_colorize_gitstring ()
  local c_lblue='\[\e[1;34m\]'
  local c_clear='\[\e[0m\]'
  fi
+
  local bad_color=$c_red
+  if [ -n "${GIT_PS1_BAD_COLOR-}" ]; then
+    bad_color=$GIT_PS1_BAD_COLOR
+  fi
+
  local ok_color=$c_green
- local flags_color="$c_lblue"
+  if [ -n "${GIT_PS1_OK_COLOR-}" ]; then
+    ok_color=$GIT_PS1_OK_COLOR
+  fi
+
+  local flags_color="$c_lblue"
+  if [ -n "${GIT_PS1_FLAGS_COLOR-}" ]; then
+    flags_color=$GIT_PS1_FLAGS_COLOR
+  fi

  local branch_color=""
  if [ $detached = no ]; then
-- 
2.1.3
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]