Skip to content

Instantly share code, notes, and snippets.

@bdougherty
Forked from xaviershay/gist:49265
Created June 7, 2009 02:32
Show Gist options
  • Save bdougherty/125113 to your computer and use it in GitHub Desktop.
Save bdougherty/125113 to your computer and use it in GitHub Desktop.
Git branch status bash prompt
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)] "
}
export PS1='\w $(get_git_prompt)>: '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment