Skip to content

Instantly share code, notes, and snippets.

@SylvainJuge
Created March 23, 2015 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SylvainJuge/ad29fb186d43a819e92d to your computer and use it in GitHub Desktop.
Save SylvainJuge/ad29fb186d43a819e92d to your computer and use it in GitHub Desktop.
#
# 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