Skip to content

Instantly share code, notes, and snippets.

@aiwas
Created May 12, 2019 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aiwas/0216d2915494a6fea4418785811a0b0c to your computer and use it in GitHub Desktop.
Save aiwas/0216d2915494a6fea4418785811a0b0c to your computer and use it in GitHub Desktop.
ターミナルで256色出すやつの再発明
print_256_bg() {
for c in {000..015}; do
echo -n "\e[7m\e[38;5;${c}m $c \e[0m"
[ $(($c%8)) -eq 7 ] && echo
done
for c in {016..255}; do
echo -n "\e[7m\e[38;5;${c}m $c \e[0m"
[ $(($c%12)) -eq 3 ] && echo
done
}
print_256() {
for c in {000..015}; do
echo -n "\e[38;5;${c}m $c "
[ $(($c%8)) -eq 7 ] && echo
done
for c in {016..255}; do
echo -n "\e[38;5;${c}m $c "
[ $(($c%12)) -eq 3 ] && echo
done
}
print_256_test() {
echo "\e[48;5;${2}m\e[38;5;${1}m FG:${1} BG:${2} "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment