Skip to content

Instantly share code, notes, and snippets.

@esundahl
Created January 21, 2012 23:23
Show Gist options
  • Save esundahl/1654492 to your computer and use it in GitHub Desktop.
Save esundahl/1654492 to your computer and use it in GitHub Desktop.
#!bash
function current_git_branch () {
# '$(__git_ps1 " %s")'
local current_branch=$(__git_ps1)
# No Branch
if [[ "$current_branch" = "" ]]; then
printf ""
# Master Branch
elif [[ "$current_branch" = "master" ]]; then
printf " (\e[0;36m$current_branch\e[m)"
# Feature Branch
elif [[ "$current_branch" == feature/* ]]; then
printf " (\e[0;34m${current_branch/feature\/}\e[m)"
# Hotfix Branch
elif [[ "$current_branch" == hotfix/* ]]; then
printf " (\e[0;31m${current_branch/hotfix\/}\e[m)"
# Release Branch
elif [[ "$current_branch" == release/* ]]; then
printf " (\e[0;35m${current_branch/release\/}\e[m)"
# Support Branch
elif [[ "$current_branch" == support/* ]]; then
printf " (\e[0;33m${current_branch/support\/}\e[m)"
else
printf " (\e[0;32m$current_branch\e[m)"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment