Last active
February 4, 2016 13:15
-
-
Save zhester/8d5a00bed20088aa9f39 to your computer and use it in GitHub Desktop.
Display foreground colors as sent by the shell.
This file contains 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/csh | |
#============================================================================ | |
# | |
# Shell Console Color Previewer | |
# | |
# Prints out all the console colors using the shell ([t]csh). | |
# | |
# The color code mappings are based on these definitions: | |
# | |
# 0 | reset colors to 37;40 | |
# 1 | bright/bold | |
# 2 | dimmed | |
# 4 | underlined | |
# 7 | reversed | |
# 30/40 | black | |
# 31/41 | red | |
# 32/42 | green | |
# 33/43 | yellow | |
# 34/44 | blue | |
# 35/45 | magenta | |
# 36/45 | cyan | |
# 37/47 | white | |
# | |
# 30s are foreground colors, 40s are background colors | |
# | |
#============================================================================ | |
# Notes: | |
# mode 3 had no effect in my console | |
# mode 5 is for blinking text, and it should never be used or work | |
# mode 6 had no effect in my console | |
# multiple modes can be combined (e.g. 2;7 for dimmed, reversed text) | |
# Iterate through each mode. | |
foreach m ( 0 1 2 4 7 ) | |
# Iterate through each foreground color. | |
foreach f ( 30 31 32 33 34 35 36 37 ) | |
# Iterate through each background color. | |
foreach b ( 40 41 42 43 44 45 46 47 ) | |
# Print a color swatch. | |
printf "\033[$m;$f;${b}m#$m;$f;$b#" | |
end | |
# Reset color before the newline or it looks bad. | |
printf "\033[0m\n" | |
end | |
# Reset color before next mode. | |
printf "\033[0m" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment