git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Custom prompt colors

From
VRVanja Radovanović <elvanja@gmail.com>
Date
Nov 10, 2014, 10:37 UTC
Message-ID
<CAC2nwfdU5i+=JugCjoLjRo0uwWMTt-_+H0akYpdmiWoK+mFSSg@mail.gmail.com>
In-Reply-To
<CAC2nwfcuPLKr-kpt-G1uUmMoZs8T+pg9uJWP5oxMea60xg09=g@mail.gmail.com>

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:
Show 55 quoted lines
> 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
Previous: Vanja Radovanović
Message 2 of 2 in “Custom prompt colors”
  1. Custom prompt colorsVanja Radovanović, Nov 10, 2014
  2. Vanja RadovanovićNov 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.