Skip to content

Instantly share code, notes, and snippets.

@fallengiants
Created February 20, 2013 04:11
Show Gist options
  • Select an option

  • Save fallengiants/4992809 to your computer and use it in GitHub Desktop.

Select an option

Save fallengiants/4992809 to your computer and use it in GitHub Desktop.
Git branch in prompt
git_prompt () {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
echo "[$git_branch]"
}
PS1="\w \$(git_prompt)\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment