Skip to content

Instantly share code, notes, and snippets.

@p120ph37
Created August 22, 2014 22:21
Show Gist options
  • Save p120ph37/15efac098fcf98d9da08 to your computer and use it in GitHub Desktop.
Save p120ph37/15efac098fcf98d9da08 to your computer and use it in GitHub Desktop.
Git Bash Prompt
# produce a colorized path string with the git branch injected at the root of the repository
PS1git='\[\e[94m\]$(git rev-parse --show-toplevel 2>/dev/null)$( \
( test -z "$(git status -s 2>/dev/null)" && __git_ps1 "\[\e[32m\](%s)" ) \
|| __git_ps1 "\[\e[91m\]{%s}" \
)\[\e[94m\]${PWD##$(git rev-parse --show-toplevel 2>/dev/null)}'
# Use where you would use "\w" in your PS1 prompt. e.g.:
PS1='${debian_chroot:+($debian_chroot)}\[\e[1;32m\]\u@\h\[\e[0m\]:'"$PS1git"'\[\e[0m\]\$'
@p120ph37
Copy link
Author

Looks something like this, but in color:

aaron@aaron:/home/aaron/myproject{myBranchOfProject}/www/javascript$

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