I have written a script that I think a lot of people online would enjoy using. Anyone who's used ANSI color codes to add colorized output to terminal programs or shell scripts knows how painful it is to have to open up some thread on Github or Stackoverflow with a table of color codes and keep referring back to it every time you want to use a new color. Wouldn't it be nice to have some terminal-based program that would do this for you?
Ladies and gentlemen, I believe I have solved this problem.
The solution is a script I wrote called
color. Here's some example output:
$ color red \e[0;31m : Red \e[1;31m : Red bold \e[4;31m : Red underline \e[41m : Red background \e[0;91m : Red high intensity \e[1;91m : Red bold high intensity \e[0;101m : Red high intensity background
When run in the terminal, the printed color code is styled with the background and color that it represents. Screenshot
Note: if a
NO_COLOR environment variable is set, the program does not use ANSI color escape sequences to color its output. See no-color.org for more information.
Simply run these commands to install the script and its dependency file.
curl -s https://spitemim.xyz/scripts/color > ~/.local/bin/color chmod +x ~/.local/bin/color curl -s https://spitemim.xyz/scripts/color.txt > ~/.local/share/colors.txt
The script doesn't print the reset code correctly. Just memorize
\e[0;0m and you won't have to worry about it.
The script now prints the reset sequence normally. Turns out I missed a backslash in colors.txt...