Skip to content

Instantly share code, notes, and snippets.

@troolee
Created April 23, 2011 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save troolee/938573 to your computer and use it in GitHub Desktop.
Save troolee/938573 to your computer and use it in GitHub Desktop.
prompt
### PROMPT ####################
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
COLOR_GRAY="\\[\\033[0;37m\\]"
COLOR_WHITE="\\[\\033[1;37m\\]"
COLOR_GREEN="\\[\\033[0;32m\\]"
COLOR_RED="\\[\\033[0;31m\\]"
COLOR_YELLOW="\\[\\033[1;33m\\]"
COLOR_BLUE="\\[\\033[1;34m\\]"
if [[ /Users/$USER != $HOME ]] ; then
PROMPT_USERNAME="$COLOR_RED$USER$COLOR_WHITE "
else
PROMPT_USERNAME=""
fi
export PS1=$PROMPT_USERNAME'$(__git_ps1 "\[\e[0;32m\]%s\[\e[0m\]\[\e[0;33m\]$(parse_git_dirty)\[\e[0m\] ")\w$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment