git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* __git_ps1_colorize__gitstring() in git_prompt.sh: colors are hardcoded?
@ 2014-10-17 17:30 nathdwek
  2014-10-20 14:45 ` Michael J Gruber
  0 siblings, 1 reply; 2+ messages in thread
From: nathdwek @ 2014-10-17 17:30 UTC (permalink / raw)
  To: git

Hello,

It seems to me that the colors used to indicate the repo's state in the
prompt are hardcoded although the top comment says otherwise.

>From contrib/completion/git-contrib.sh:

[83]# If you would like a colored hint about the current dirty state, set
# 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.

[228]__git_ps1_colorize_gitstring ()
{
	if [[ -n ${ZSH_VERSION-} ]]; then
		local c_red='%F{red}'
		local c_green='%F{green}'
		local c_lblue='%F{blue}'
		local c_clear='%f'
	else
		# Using \[ and \] around colors is necessary to prevent
		# issues with command line editing/browsing/completion!
		local c_red='\[\e[31m\]'
		local c_green='\[\e[32m\]'
		local c_lblue='\[\e[1;34m\]'
		local c_clear='\[\e[0m\]'
	fi
	local bad_color=$c_red
	local ok_color=$c_green
	local flags_color="$c_lblue"

	local branch_color=""


As expected upon seeing this snippet, the color.status.<slot> entries in
the git config file do modify the git status -sb output but don't modify
the colors used in the prompt.

Regards,

Nathan

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: __git_ps1_colorize__gitstring() in git_prompt.sh: colors are hardcoded?
  2014-10-17 17:30 __git_ps1_colorize__gitstring() in git_prompt.sh: colors are hardcoded? nathdwek
@ 2014-10-20 14:45 ` Michael J Gruber
  0 siblings, 0 replies; 2+ messages in thread
From: Michael J Gruber @ 2014-10-20 14:45 UTC (permalink / raw)
  To: nathdwek, git

nathdwek schrieb am 17.10.2014 um 19:30:
> Hello,
> 
> It seems to me that the colors used to indicate the repo's state in the
> prompt are hardcoded although the top comment says otherwise.
> 
> From contrib/completion/git-contrib.sh:
> 
> [83]# If you would like a colored hint about the current dirty state, set
> # 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.

That should have said "... on the default colors used for the colored
output of..."

> [228]__git_ps1_colorize_gitstring ()
> {
> 	if [[ -n ${ZSH_VERSION-} ]]; then
> 		local c_red='%F{red}'
> 		local c_green='%F{green}'
> 		local c_lblue='%F{blue}'
> 		local c_clear='%f'
> 	else
> 		# Using \[ and \] around colors is necessary to prevent
> 		# issues with command line editing/browsing/completion!
> 		local c_red='\[\e[31m\]'
> 		local c_green='\[\e[32m\]'
> 		local c_lblue='\[\e[1;34m\]'
> 		local c_clear='\[\e[0m\]'
> 	fi
> 	local bad_color=$c_red
> 	local ok_color=$c_green
> 	local flags_color="$c_lblue"
> 
> 	local branch_color=""
> 
> 
> As expected upon seeing this snippet, the color.status.<slot> entries in
> the git config file do modify the git status -sb output but don't modify
> the colors used in the prompt.
> 
> Regards,
> 
> Nathan

The script could query config for these colors, but that would amount to
4 additional forks and "git config" calls each time a prompt is
generated. If you want the colors to be configurable, you should
probably rather introduce environment variables - or edit your copy of
the script ;)

Cheers,
Michael

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-20 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-17 17:30 __git_ps1_colorize__gitstring() in git_prompt.sh: colors are hardcoded? nathdwek
2014-10-20 14:45 ` Michael J Gruber

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).