git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vanja Radovanović" <elvanja@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Custom prompt colors
Date: Mon, 10 Nov 2014 10:42:23 +0100	[thread overview]
Message-ID: <CAC2nwfcuPLKr-kpt-G1uUmMoZs8T+pg9uJWP5oxMea60xg09=g@mail.gmail.com> (raw)

>From 41e9edae533306b4a50570e32dbbdd291a4a5fbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vanja=20Radovanovi=C4=87?= <elvanja@gmail.com>
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

             reply	other threads:[~2014-11-10  9:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-10  9:42 Vanja Radovanović [this message]
2014-11-10 10:37 ` [PATCH] Custom prompt colors Vanja Radovanović

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC2nwfcuPLKr-kpt-G1uUmMoZs8T+pg9uJWP5oxMea60xg09=g@mail.gmail.com' \
    --to=elvanja@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).