Skip to content

Instantly share code, notes, and snippets.

@andkirby
Created October 22, 2016 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andkirby/c6151b965ec61dea88626c660651b16c to your computer and use it in GitHub Desktop.
Save andkirby/c6151b965ec61dea88626c660651b16c to your computer and use it in GitHub Desktop.
colored text in bash
# t_color COLOR_NO MESSAGE [STYLE_NO]
t_color () {
local style
style=$([ -n "$3" ] && echo 0 || echo $3)
echo -e '\e['$3';'$1'm'$2'\e[0m'
}
t_warning () {
echo -e '\e[0;33m'$1'\e[0m'
}
t_ok () {
echo -e '\e[0;32m'$1'\e[0m'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment