Skip to content

Instantly share code, notes, and snippets.

@AVGP
Created December 23, 2016 14:31
Show Gist options
  • Save AVGP/2799d91865a09378d79fdacfef9ea6b1 to your computer and use it in GitHub Desktop.
Save AVGP/2799d91865a09378d79fdacfef9ea6b1 to your computer and use it in GitHub Desktop.
SCM command prompt
DEFAULT="[0m" #"[37;40m"
PINK="[35m"
GREEN="[32m"
ORANGE="[33m"
scm_branch() {
HG_BRANCH=`hg branch 2> /dev/null`
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD 2> /dev/null`
if [ -n "$HG_BRANCH" ]; then
BRANCH="\e${DEFAULT} on \e${ORANGE}hg:$HG_BRANCH\e${DEFAULT}"
elif [ -n "$GIT_BRANCH" ]; then
BRANCH="\e${DEFAULT} on \e${ORANGE}git:$GIT_BRANCH\e${DEFAULT}"
fi
echo -e "$BRANCH"
}
export PS1='\n\e${PINK}\u \
\e${DEFAULT}in \e${GREEN}\w\
\e${DEFAULT}$(scm_branch) \n\$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment