Skip to content

Instantly share code, notes, and snippets.

@danieldietrich
Last active February 22, 2019 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieldietrich/796d0c481539c930c49fa5a8663fa2b2 to your computer and use it in GitHub Desktop.
Save danieldietrich/796d0c481539c930c49fa5a8663fa2b2 to your computer and use it in GitHub Desktop.
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