Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Git prompt
# -----------------------------------------------------------------------------
# This is a fragment of ~/.bash_profile that adds git status and branch
# information to the terminal prompt. The 'colors' section is optional.
# -----------------------------------------------------------------------------
# prompt
export PS1="\[\e[0;32m\]\u@\h:\[\e[1;36m\]\w\[\e[0;33m\]\$(parse_git_status)\[\e[1;32m\]\$(parse_git_branch)\[\e[1;36m\] $\[\e[0m\] "
# colors
export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
# git helpers
parse_git_branch() {
git branch --no-color 2>/dev/null | grep -E '^\*' | sed 's/\* /⎇ /'
parse_git_status() {
git status --porcelain 2>/dev/null | head -c1 | if [ $(wc -c) -gt "0" ]; then echo "?"; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.