Skip to content

Instantly share code, notes, and snippets.

@yaniv-aknin
Last active December 12, 2015 02:48
Show Gist options
  • Select an option

  • Save yaniv-aknin/4701096 to your computer and use it in GitHub Desktop.

Select an option

Save yaniv-aknin/4701096 to your computer and use it in GitHub Desktop.
Can you think of a better console text colouring library for shell?
#!sh
function newline() { printf "$@\n"; }
function color() {
output="\e[$1m"
shift
[ -n "$1" ] && output="$output$@\e[00m"
printf "$output"
}
function reset() { color "00"; }
function red() { color "01;31" "$@"; }
function white() { color "01;37" "$@" ; }
function warning() {
newline "$(red "$@")"
}
function suggestion() {
newline "(run $(white "$1") if you want me to take care of this)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment