Created
September 21, 2015 06:05
-
-
Save adamheins/34f6dc643d9b231a078d to your computer and use it in GitHub Desktop.
Bash function for displaying all 256 colors with codes in the terminal.
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
#!/bin/bash | |
# Print all of the terminal colors. | |
colors() { | |
local count=0 | |
local cols=$(tput cols) | |
for i in {0..255}; do | |
((count+=4)) | |
if [ $count -gt $cols ]; then | |
printf "\n" | |
count=4 | |
fi | |
printf "\x1b[38;5;${i}m%03s " "${i}" | |
done | |
printf "\n" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment