Skip to content

Instantly share code, notes, and snippets.

@nickboldt
Created February 5, 2015 19:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nickboldt/fab71da10bd5169ffdfa to your computer and use it in GitHub Desktop.
Save nickboldt/fab71da10bd5169ffdfa to your computer and use it in GitHub Desktop.
add colour to git branch info
#!/bin/bash
# http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
red="$(tput setaf 1)"
green="$(tput setaf 2)"
blue="$(tput setaf 4)"
white="$(tput setaf 7;tput dim)"
underline_on="$(tput smul)"
underline_off="$(tput rmul)"
echo -n $white"git branch -v"
git branch -v | sed -e "s/\(\[behind\|, behind \)/$red\1/" -e "s/\(\[ahead\)/$green\1/" -e "s/\]/\]$white/" \
-e "s#\(\(JBIDE\|JBDS\)-[0-9]\+\)#$blue\1$white#g" \
-e "s#\([0-9]\+\.[0-9]\+\.[0-9]\+\([0-9_.]\+\|.SNAPSHOT\)\)#${underline_on}\1${underline_off}#g" \
-e "s#\([0-9]\+\.[0-9]\+\.[0-9]\+\(\(.Final\|.CR\|.Beta\|.Alpha\|.\)[0-9_.]\+\)\)#${underline_on}\1${underline_off}#g" \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment