Skip to content

Instantly share code, notes, and snippets.

@adamheins
Created September 21, 2015 06:05
Show Gist options
  • Save adamheins/34f6dc643d9b231a078d to your computer and use it in GitHub Desktop.
Save adamheins/34f6dc643d9b231a078d to your computer and use it in GitHub Desktop.
Bash function for displaying all 256 colors with codes in the terminal.
#!/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