Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Last active August 29, 2015 13:59
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 knowtheory/10547187 to your computer and use it in GitHub Desktop.
Save knowtheory/10547187 to your computer and use it in GitHub Desktop.
Include this in your .bash_profile to get colors, info and autocompletion on your prompt (if git is installed via homebrew)
# Git comes with some shell scripts you can load to get
# nifty shell features. Homebrew sticks them in /usr/local/etc/bash_completion.d
source "/usr/local/etc/bash_completion.d/git-prompt.sh"
source "/usr/local/etc/bash_completion.d/git-completion.bash"
# apparently you can specify __git_ps1 as the thing that
# renders your prompt by setting PROMPT_COMMAND.
# Setting the PROMPT_COMMAND lets git display colors.
#
# The alternative is just to set the PS1 variable.
#
# the "\u@\h:\W" "\\\$ " bit says "
# display the user,
# an @ sign,
# the hostname of your machine
# a colon
# the current directory
# and then some git stuff
export PROMPT_COMMAND='__git_ps1 "\u@\h:\W" "\\\$ "'
# and we can tell it what to show us.
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="auto"
export GIT_PS1_SHOWCOLORHINTS=true
@knowtheory
Copy link
Author

It looks like this:

prompt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment