Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created July 23, 2014 22:52
Show Gist options
  • Save miguelmota/0beb2b28070408c5a13b to your computer and use it in GitHub Desktop.
Save miguelmota/0beb2b28070408c5a13b to your computer and use it in GitHub Desktop.
Bash prompt with git branch status
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\n\n\[\033[0;36m\]\u@$(hostname)\[\033[00m\]\[\033[0;32m\] : \w\[\033[00m\] \[\033[00;36m\]$(parse_git_branch)\n\[\033[00;32m\]\$\[\033[00m\] '
export PS2="\[\033[0;32m\]>\[\033[00m\] "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment