Skip to content

Instantly share code, notes, and snippets.

@readysetawesome
Created October 7, 2012 16:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save readysetawesome/3848872 to your computer and use it in GitHub Desktop.
Save readysetawesome/3848872 to your computer and use it in GitHub Desktop.
Color coded bash prompt showing GIT repository name, branch name, working directory state (clean/dirty)
export PS1='$(git branch &>/dev/null; if [ $? -eq 0 ]; then \
echo "\[\e[0;32m\][GIT: \[\e[0;31m\]$(basename `pwd`); \[\e[0;33m\]$(git branch | grep ^*|sed s/\*\ //) \
$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; if [ "$?" -eq "0" ]; then \
echo "\[\e[0;32m\]clean"; else \
echo "\[\e[0;31m\]dirty"; fi)\[\e[0;32m\]] \$ "; else \
echo "\[\e[0;31m\][\w]\[\e[m\] \$ "; fi) \[\e[0m\]'
@keflavich
Copy link

My version, inspired by yours:
https://gist.github.com/4383597

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