1
0
Fork 0
dotfiles/.config/zsh/functions/ansi-colours

37 lines
1.2 KiB
Bash

#!/usr/bin/env zsh
# Prints ANSI colours along with their escape codes.
# https://tintin.mudhalla.net/info/256color/
print "\e[1;97mClassic colours:\e[0m"
print "Regular Bold Underline Background"
for n in {30..37}; do
local nbg=$(( ${n} + 10 ))
print -c "\e[0;${n}m\\\e[0;${n}m\e[m" "\e[1;${n}m\\\e[1;${n}m\e[m" \
"\e[4;${n}m\\\e[4;${n}m\e[m" "\e[${nbg}m\\\e[${nbg}m\e[m"
done
print "\n\e[1;97mHigh intensity colours:\e[0m"
print "Regular Bold Underline Background"
for n in {90..97}; do
local nbg=$(( ${n} + 10 ))
print -c "\e[0;${n}m\\\e[0;${n}m\e[m" "\e[1;${n}m\\\e[1;${n}m\e[m" \
"\e[4;${n}m\\\e[4;${n}m\e[m" "\e[${nbg}m\\\e[${nbg}m\e[m"
done
print "\n\e[1;97m256 colour pallette:\e[0m"
local -a colours
for n in {0..15}; do
colours+="\e[38;5;${n}m\\\e[38;5;${n}m\e[0m"
done
print -C 2 ${colours}
colours=()
for n in {16..255}; do
colours+="\e[38;5;${n}m\\\e[38;5;${n}m\e[0m"
done
print -C 6 -a ${colours}
print "\n\e[1;97m256 colour background:\e[0m 48 instead of 38"
print "\e[1;97mTrue colour:\e[0m \\\e[38;2;\e[0;31mR\e[0m;\e[0;32mG\e[0m;\e[0;34mB\e[0mm" \
"and \\\e[48;2;\e[0;41mR\e[0m;\e[0;42mG\e[0m;\e[0;44mB\e[0mm"
print "\e[1;97mReset:\e[0m \\\e[0m"