Skip to content

Instantly share code, notes, and snippets.

@mindo
Last active October 13, 2015 02:27
Show Gist options
  • Save mindo/4124388 to your computer and use it in GitHub Desktop.
Save mindo/4124388 to your computer and use it in GitHub Desktop.
see git/mercurial branch on command prompt
function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\[\1\]\ /'
}
function parse_hg_branch_and_add_brackets {
hg branch 2> /dev/null | sed -e 's/\(.*\)/\[\1\]\ /'
}
PS1="$XTERM_TITLE$USER_COLOR\u\[\e[36;1m\]@\[\e[31;1m\]\h:\[\e[m\] \[\e[1;34m\]\w\[\e[m\]\n\[\033[0;32m\]$(parse_git_branch_and_add_brackets)$(parse_hg_branch_and_add_brackets)\[\e[36;1m\]$DOLLAR$BGJOBS \[\e[m\]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment