* [PATCH] Custom prompt colors
@ 2014-11-10 9:42 Vanja Radovanović
2014-11-10 10:37 ` Vanja Radovanović
0 siblings, 1 reply; 2+ messages in thread
From: Vanja Radovanović @ 2014-11-10 9:42 UTC (permalink / raw)
To: git
>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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Custom prompt colors
2014-11-10 9:42 [PATCH] Custom prompt colors Vanja Radovanović
@ 2014-11-10 10:37 ` Vanja Radovanović
0 siblings, 0 replies; 2+ messages in thread
From: Vanja Radovanović @ 2014-11-10 10:37 UTC (permalink / raw)
To: git
http://git.661346.n2.nabble.com/PATCH-Custom-prompt-colors-td7620939.html
“Art has no limits.
Just like me!”
by Ponce
On Mon, Nov 10, 2014 at 10:42 AM, Vanja Radovanović <elvanja@gmail.com> wrote:
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-10 10:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-10 9:42 [PATCH] Custom prompt colors Vanja Radovanović
2014-11-10 10:37 ` Vanja Radovanović
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).