Skip to content

Instantly share code, notes, and snippets.

@cczona
Created August 25, 2012 19:08
Show Gist options
  • Save cczona/3469469 to your computer and use it in GitHub Desktop.
Save cczona/3469469 to your computer and use it in GitHub Desktop.
My Git/RVM bash shell prompt
### Bash shell prompt with RVM and Git info ###
### REQUIRES git-prompt.sh provided with Git ###
# $ cp git-prompt.sh ~/.git-prompt.sh
# $ echo source ~/.git-completion.sh >> ~/.bashrc
# in ~/.bashrc
BLACK="\e[30m"
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
PURPLE="\e[35m"
CYAN="\e[36m"
WHITE="\e[37m"
COLOR=$BLACK #default
if [[ $HOSTNAME =~ '.local' ]]; then COLOR=$BLACK
elif [[ $HOSTNAME =~ 'joyent.us' ]]; then COLOR=$PURPLE
fi
function git_dirty {
git status -s 2>/dev/null | sed /^#/d | wc -l | tr -d ' '
}
function git_repo {
git rev-parse --show-toplevel
}
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
PS1="\\n\\n\
$PURPLE\$(git_dirty) \
$YELLOW\$(__git_ps1 \"#%s\")\
$COLOR \
\$(git_repo) \
\$(~/.rvm/bin/rvm-prompt v p g s)\
\\n\
[\w] "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment