Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.