Skip to content

Instantly share code, notes, and snippets.

@marek-saji
Last active December 14, 2015 12:59
Show Gist options
  • Save marek-saji/5090416 to your computer and use it in GitHub Desktop.
Save marek-saji/5090416 to your computer and use it in GitHub Desktop.
Add this to your .bashrc to include current git tag/branch in shell prompt.
PS1_git() {
BRANCH="$( git rev-parse --abbrev-ref HEAD 2>/dev/null )"
BRANCH="$( git describe --abbrev=0 --tags --match="$BRANCH-*" 2>/dev/null || echo "$BRANCH" )"
test -n "$BRANCH" && echo "($BRANCH) "
}
PS1="\[\033[0;34m\]\$( PS1_git )\[\033[0m\]$PS1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment