Skip to content

Instantly share code, notes, and snippets.

@tdd
Created July 16, 2015 09:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tdd/594d37179ee9b36e1ba3 to your computer and use it in GitHub Desktop.
Save tdd/594d37179ee9b36e1ba3 to your computer and use it in GitHub Desktop.
Bash prompt configuration for Git’s built-in prompt features
# STEP 1: ENSURE COMPLETION AND PROMPT FUNCTION ARE LOADED
# ========================================================
# OPTION 1: If on OSX using Homebrew:
#
# source $(brew --prefix)/etc/bash_completion.d/git-prompt.sh
# source $(brew --prefix)/etc/bash_completion.d/git-completion.bash
# OPTION 2: If on OSX using built-in Git (also works on ZSH):
#
# source /usr/local/git/contrib/completion/git-prompt.sh
# source /usr/local/git/contrib/completion/git-completion.bash
# OPTION 3: If on Ubuntu/Debian/Mint using standard packages, or on Windows: pre-loaded!
# STEP 2: CONFIGURE THE PROMPT
# ============================
# Configure `__git_ps1` to tell us as much as possible
export GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWSTASHSTATE=1 GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM=verbose GIT_PS1_DESCRIBE_STYLE=branch GIT_PS1_SHOWCOLORHINTS=1
export GIT_PS1_HIDE_IF_PWD_IGNORED=1
# Colorful prompt for Bash!
export PS1='\[\e[0;36m\][\A] \u@\h:\[\e[0m\e[0;32m\]\W\[\e[1;33m\]$(__git_ps1 " (%s)")\[\e[0;37m\] \$\[\e[0m\] '
# Or if you want the basic prompt, no colors, no timestamps, just regular + Git info:
# export PS1='\u@\h:\W$(__git_ps1 " (%s)")\$ '
# Unrelated but useful: avoid auto-édit on successful merges, starting with Git 2.0
export GIT_MERGE_AUTOEDIT=no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment