Skip to content

Instantly share code, notes, and snippets.

@ungoldman
Created January 9, 2012 18:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ungoldman/1584339 to your computer and use it in GitHub Desktop.
Save ungoldman/1584339 to your computer and use it in GitHub Desktop.
get git branch info in bash cli
# git branch bedazzler (.each_line added before .grep for 1.9.x)
# http://asemanfar.com/Current-Git-Branch-in-Bash-Prompt
export PS1="\[\033[32m\]ツ\[\033[0m\] \[\033[37m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\`ruby -e \"print (%x{git branch 2> /dev/null}.each_line.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[37m\]$\[\033[00m\] "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment