Skip to content

Instantly share code, notes, and snippets.

@jxson
Created September 21, 2011 18:52
Show Gist options
  • Save jxson/1232968 to your computer and use it in GitHub Desktop.
Save jxson/1232968 to your computer and use it in GitHub Desktop.
Git info in your `bash` prompt like ~/Code/haiku (trusting) ☠
export COLOR_NONE='\[\e[0m\]' # No Color
export COLOR_LIGHT_PURPLE='\[\e[1;35m\]'
# Get the name of the branch we are on
git_prompt_info() {
branch_prompt=$(__git_ps1)
if [ -n "$branch_prompt" ]; then
status_icon=$(git_status)
echo $branch_prompt $status_icon
fi
}
# Show character if changes are pending
git_status() {
if current_git_status=$(git status | grep 'added to commit' 2> /dev/null); then
echo "☠"
fi
}
PS1='\u@\h: \w $(git_prompt_info " (%s)")\n'$COLOR_LIGHT_PURPLE'→ '$COLOR_NONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment