Fix git prompt when showuntrackedfiles is set
authorMikael Berthe <mikael@lilotux.net>
Sun, 15 Jul 2012 10:40:16 +0200
changeset 11 ee97df34536f
parent 10 ed98b8ea395d
child 12 a906009be2b1
Fix git prompt when showuntrackedfiles is set When GIT_PS1_SHOWUNTRACKEDFILES is set, the output of __git_ps1 may contain a '%', which needs to be escaped before we can use it in the shell prompt.
zshrc.d/20-prompt.zrc
--- a/zshrc.d/20-prompt.zrc	Sun Jul 15 01:58:11 2012 +0200
+++ b/zshrc.d/20-prompt.zrc	Sun Jul 15 10:40:16 2012 +0200
@@ -39,6 +39,8 @@
 source $ZDOTDIR/tools/git-prompt.sh > /dev/null 2>&1
 function __git_prompt_info {
   r=$(__git_ps1)
+  # If GIT_PS1_SHOWUNTRACKEDFILES is used, we need to escape the %
+  r=${r//\%/%%}
   if [ ! -z $r ]; then echo -e "\n%Bgit%b$r"; fi
 }