Skip to content

Instantly share code, notes, and snippets.

@blackjack
Created February 5, 2016 12:48
Show Gist options
  • Save blackjack/338c6cbdc184b2d17218 to your computer and use it in GitHub Desktop.
Save blackjack/338c6cbdc184b2d17218 to your computer and use it in GitHub Desktop.
Hl function
function hl {
if [ "$#" -le 1 ]
then
colorname="red"
pattern=$1
else
colorname=$1
pattern=$2
fi
case $colorname in
red)
color=$(tput bold;tput setaf 1)
;;
green)
color=$(tput bold;tput setaf 2)
;;
yellow)
color=$(tput bold;tput setaf 3)
;;
blue)
color=$(tput bold;tput setaf 4)
;;
purple)
color=$(tput bold;tput setaf 5)
;;
cyan)
color=$(tput bold;tput setaf 6)
;;
grey)
color=$(tput bold;tput setaf 7)
;;
*)
esac
normal=$(tput sgr0)
sed -u -e "s/\($pattern\)/$color\1$normal/"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment