DORMANTno replies

[PATCH] git-prompt.sh not working with vcs_info under zsh

From: Alexander Adolf <hidden>
Date: 2021-06-05 15:42:13

Hello,

I discovered and fixed a small glitch in git-prompt.sh in conjunction
with zsh's vcs_info library. I prefer using git-prompt.sh through
vcs_info because it allows me to leverage the support of other version
control systems provided by vcs_info, and still get the more detailed
information provided by git-prompt.sh. Best-of-both-worlds approach. ;-)

The issue is that the prompt_subst option (required for using vcs_info)
breaks the rendering of the percent character to indicate untracked
objects. More details in the attached patch.

For the curious, here is the relevant snippet from my ~/.zshrc:
---------------------------- Begin Quote -----------------------------
setopt prompt_subst
autoload -U promptinit; promptinit
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git svn cvs hg
zstyle ':vcs_info:*' check-for-changes true
source ~/.zsh/git-prompt.sh	# defines __git_ps1()
GIT_PS1_SHOWCOLORHINTS="1"	# colors are based on the colored output of "git status -sb"
GIT_PS1_SHOWDIRTYSTATE="1"	# '*' unstaged and '+' staged changes
GIT_PS1_SHOWSTASHSTATE="1"	# '$' if something is stashed
GIT_PS1_SHOWUNTRACKEDFILES="1"	# '%' if untracked files exist
GIT_PS1_SHOWUPSTREAM=('name' 'verbose' 'git')
function git-ps1-wrapper () { reply=" (%s:$(__git_ps1 '%s'))" }
zstyle -e ':vcs_info:git:*' formats       'git-ps1-wrapper'
zstyle -e ':vcs_info:git:*' actionformats 'git-ps1-wrapper'
zstyle  ':vcs_info:*'     formats       ' (%s:%b%u%c)'
zstyle  ':vcs_info:*'     actionformats ' (%s:%b%u%c|%a)'
precmd () { vcs_info }
PROMPT='
%B%m:%2~%b${vcs_info_msg_0_}
%B%(!.#.▶)%b '
----------------------------- End Quote ------------------------------


Many thanks, looking forward to your thoughts, and have a great weekend,

  --alexander

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help