Skip to content

Instantly share code, notes, and snippets.

@rodreegez
Created March 24, 2010 16:14
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 rodreegez/342448 to your computer and use it in GitHub Desktop.
Save rodreegez/342448 to your computer and use it in GitHub Desktop.
# get current git branch
git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
echo "[${ref#refs/heads/}]"
fi
}
# set prompt a la Ubuntu, but with added git branch (if any)
export PS1='\u@\h:$(git_prompt_info)\w$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment