Skip to content

Instantly share code, notes, and snippets.

@noahhendrix
Created February 13, 2012 06:03
Show Gist options
  • Save noahhendrix/1814133 to your computer and use it in GitHub Desktop.
Save noahhendrix/1814133 to your computer and use it in GitHub Desktop.
#functions
#is the branch dirty, if so echo a *
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
#if in a git repo echo branch name and dirty status
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}"`parse_git_dirty`)"
}
# this makes tab-completion nicer, because it ignore
# case, so `cd co[TAB]` will complete to `cd Code`
bind 'set completion-ignore-case on'
# export PS1="$GREEN\w $YELLOW\$(parse_git_branch)$NO_COLOR → "
PS1="\[\033[1;32m\]\w \[\033[1;33m\]\$(parse_git_branch)\[\033[0m\] → "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment