Created
June 9, 2013 16:47
-
-
Save stantonk/5744223 to your computer and use it in GitHub Desktop.
View branch name in command prompt for git and hg repositories, as well as current applied patch queue for mercurial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################### | |
# Command line prompt settings | |
################################################### | |
__git_hg_ps1 () { | |
local b="$(git symbolic-ref HEAD 2>/dev/null)"; | |
if [ -n "$b" ]; then | |
printf " [%s]" "${b##refs/heads/}"; | |
elif [ "$(hg root 2> /dev/null)" ]; then | |
printf " [%s]" "$(hg branch)" | |
fi | |
} | |
__hg_qtop_ps1 () { | |
if [ "$(hg root 2> /dev/null)" ]; then | |
NOPATCHES="no patches applied" | |
QTOP="$(hg qtop)" | |
if [ "$QTOP" == "$NOPATCHES" ]; then | |
printf "" | |
else | |
printf " {%s}" "$(hg qtop)" | |
fi | |
fi | |
} | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxCxDxBxegedabagacad | |
# start a color block \[\e[0;36m\] | |
# end a color block \[\e[m\] | |
declare -x PS1='\[\e[0;36m\]\h\[\e[m\] \W\[\e[0;32m\]$(__git_hg_ps1)\[\e[m\]\[\e[0;34m\]$(__hg_qtop_ps1)\[\e[m\] $ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment