I'm new to git and I'm trying to add the current git branch to my already existing prompt, which is defined as follows :
RESET="[17]"
NORMAL="[33[0m]"
RED="[33[31;1m]"
YELLOW="[33[33;1m]"
WHITE="[33[37;1m]"
SMILEY="${WHITE}:)${NORMAL}"
FROWNY="${RED}:(${NORMAL}"
SELECT="if [ $? = 0 ]; then echo "${SMILEY}"; else echo "${FROWNY}"; fi"
export PS1="${RESET}${YELLOW}u@h${NORMAL} `${SELECT}` ${YELLOW}w $(__git_ps1) >${NORMAL} "
I tried it (by sourcing my .bashrc
file again) and it seemed to work, but then I went on another branch and it did not update. How can I make sure the $(__git_ps1)
is not cached?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…