Re: [PATCH] Add __git_ps1_pc to use as PROMPT_COMMAND
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:55
Michael J Gruber [off-list ref] writes:
Junio C Hamano venit, vidit, dixit 01.10.2012 23:09:quoted
Confused....The "problem" (as far as I see) is only: What user interface do we want to expose to the user, or rather, do we want to expose the user to ;) So far, we say: # 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh). # 2) Add the following line to your .bashrc/.zshrc: # source ~/.git-prompt.sh # 3) Change your PS1 to also show the current branch: # Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' # ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' (That's incomplete for zsh, but I'm digressing...). With the above, we would change the bash instruction to PROMPT_COMMAND=' PS1=$(printf "\u \h \w %s$ " $(__git_ps1 "%s")) ' which may look more complicated to some. I think we can aim for something like PROMPT_COMMAND='__git_ps1_color "\u \h \w%s$ " " (%s)"'
If your goal is to use PROMPT_COMMAND and not PS1, then yes between the two definitions of PROMPT_COMMAND above, the latter may look simpler. But that does not explain why you want to prefer it over PS1 in the first place, which was the central point of my question that still has not been answered. Even more confused...