Skip to content

Instantly share code, notes, and snippets.

@zdennis
Created June 14, 2012 23:42
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zdennis/2933686 to your computer and use it in GitHub Desktop.
Save zdennis/2933686 to your computer and use it in GitHub Desktop.
Prompt additions for Git shell
#
# PLACE THE CONTENTS IN YOUR ~/.bashrc
# AFTERWARDS YOU'LL NEED TO RELOAD IT: source ~/.bashrc
#
# Colors
BLACK='\[\e[0;30m\]'
BLUE='\[\e[0;34m\]'
GREEN='\[\e[0;32m\]'
CYAN='\[\e[0;36m\]'
RED='\[\e[0;31m\]'
PURPLE='\[\e[0;35m\]'
BROWN='\[\e[0;33m\]'
LIGHTGRAY='\[\e[0;37m\]'
DARKGRAY='\[\e[1;30m\]'
LIGHTBLUE='\[\e[1;34m\]'
LIGHTGREEN='\[\e[1;32m\]'
LIGHTCYAN='\[\e[1;36m\]'
LIGHTRED='\[\e[1;31m\]'
LIGHTPURPLE='\[\e[1;35m\]'
YELLOW='\[\e[1;33m\]'
WHITE='\[\e[1;37m\]'
NC='\[\033[00m\]' #'\e[0m' # No Color
# make git branch show up in prompt
parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ git:\1/' ; }
parse_has_git_submodules() {
if [ -f .gitmodules ]; then
echo "*"
fi
}
function git_prompt_additions
{
if [ $? -eq 0 ]; then
echo "$(parse_git_branch)$(parse_has_git_submodules)"
else
echo "died: $?" >> /tmp/gitrclog
fi
}
export PS1="${YELLOW}\w${CYAN}\$(git_prompt_additions)${NC} "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment