Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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