Skip to content

Instantly share code, notes, and snippets.

@TaurusOlson
Forked from bdougherty/gist:125113
Created February 25, 2011 12:56
Show Gist options
  • Save TaurusOlson/843746 to your computer and use it in GitHub Desktop.
Save TaurusOlson/843746 to your computer and use it in GitHub Desktop.
My git bash prompt
# Functions for displaying git branch and status
function get_git_branch {
git branch | awk '/^\*/ { print $2 }'
}
function get_git_dirty {
git diff --quiet || echo '*'
}
function get_git_prompt {
git branch &> /dev/null || return 1
echo "[$(get_git_branch)$(get_git_dirty)] "
}
# Colors
RED="\[\033[0;31m\]"
BLUE="\[\033[0;34m\]"
NORMAL="\[\033[00m\]"
# Prompt with integrated git branch
PS1="${BLUE}(${RED}\w${BLUE})\n${RED}\u${BLUE}@\h ${RED}"
PS1=${PS1}'$(get_git_prompt)'
PS1=${PS1}"\$ ${NORMAL}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment