Created
November 6, 2017 16:42
-
-
Save hypergig/c581777bde9c3118c805142adfc7eb77 to your computer and use it in GitHub Desktop.
color echo for bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# add colorized echos as functions | |
declare -A colors | |
colors=( | |
# black | |
[bla]='0;30' | |
# red | |
[r]='0;31' | |
# green | |
[g]='0;32' | |
# brown/orange | |
[o]='0;33' | |
# blue | |
[blu]='0;34' | |
# purple | |
[p]='0;35' | |
# cyan | |
[c]='0;36' | |
# light gray | |
[lgra]='0;37' | |
# dark gray | |
[dgra]='1;30' | |
# light red | |
[lr]='1;31' | |
# light green | |
[lgre]='1;32' | |
# yellow | |
[y]='1;33' | |
# light blue | |
[lblu]='1;34' | |
# light purple | |
[lp]='1;35' | |
# light cyan | |
[lc]='1;36' | |
# white | |
[w]='1;37' | |
) | |
for c in "${!colors[@]}" | |
do | |
eval "${c}echo() { echo -e \"\033[${colors[$c]}m\$@\033[0m\"; }" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script adds a whole bunch of fun new
echo
s to your shell. Justsource
this file and typepecho hello
for a purple hello. See line 6 for all the different types ofecho
s you get!