Created
March 23, 2015 12:41
-
-
Save SylvainJuge/ad29fb186d43a819e92d to your computer and use it in GitHub Desktop.
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
# | |
# 1) add function to add to your ~/.profile or ~/.bashrc (or aliases) file | |
# | |
_current_branch () { | |
ref=$(git symbolic-ref HEAD 2>/dev/null) || head=$(git rev-parse --short HEAD 2>/dev/null) | |
echo ${ref#refs/heads/} | |
} | |
# | |
# 2) add function call to your prompt | |
# | |
# /!\ take care to escape $ to evaluate expression each time it's displayed | |
# | |
export PS1="$PS1 \$(_current_branch) >" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment