Skip to content

Instantly share code, notes, and snippets.

@gamefiend
Created November 17, 2016 17:51
Show Gist options
  • Save gamefiend/aa12bb143c702eb5aa9b56e58d3d7d58 to your computer and use it in GitHub Desktop.
Save gamefiend/aa12bb143c702eb5aa9b56e58d3d7d58 to your computer and use it in GitHub Desktop.
Display current git branch in your prompt....
#include this function in the bashrc
function parse_git_branch {
ref=$(/usr/bin/git symbolic-ref HEAD 2> /dev/null)
if [ -z $ref ]; then
echo "| - |"
else
echo "|"${ref#refs/heads/}"|"
fi
}
# then you can insert the function into your prompt like so:
PS1="\u@\h $(parse_git_branch) :"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment