Skip to content

Instantly share code, notes, and snippets.

@obstschale
Last active September 6, 2017 14:29
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 obstschale/1e1789730a399131d490e30e421e229b to your computer and use it in GitHub Desktop.
Save obstschale/1e1789730a399131d490e30e421e229b to your computer and use it in GitHub Desktop.
cecho() {
local code="\033["
case "$1" in
black | bk) color="${code}0;30m";;
red | r) color="${code}1;31m";;
green | g) color="${code}1;32m";;
yellow | y) color="${code}1;33m";;
blue | b) color="${code}1;34m";;
purple | p) color="${code}1;35m";;
cyan | c) color="${code}1;36m";;
gray | gr) color="${code}0;37m";;
*) local text="$1"
esac
[ -z "$text" ] && local text="$color$2${code}0m"
echo -e "$text" # The -e flag is needed on macOS. Other systems might not need it.
}
cecho "Normal"
cecho y "Yellow!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment