Created
November 17, 2016 17:51
-
-
Save gamefiend/aa12bb143c702eb5aa9b56e58d3d7d58 to your computer and use it in GitHub Desktop.
Display current git branch in your prompt....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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