Skip to content

Instantly share code, notes, and snippets.

@oisin
Forked from bdougherty/gist:125113
Last active December 10, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save oisin/4444722 to your computer and use it in GitHub Desktop.
Save oisin/4444722 to your computer and use it in GitHub Desktop.
get_git_branch() {
git branch | awk '/^\*/ { print $2 }'
}
get_git_dirty() {
git diff --quiet || echo '*'
}
get_git_prompt() {
git branch &> /dev/null || return 1
echo "[$(get_git_branch)$(get_git_dirty)] "
}
export PS1='$(get_git_prompt) \!% '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment