Created
January 25, 2018 00:55
-
-
Save beatak/d25385d4c636a927e284783124e1e209 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
target_shell=$1 | |
if [ -z "$1" ]; then | |
target_shell=$(basename "$SHELL") | |
fi | |
if [ "$target_shell" = "bash" ]; then | |
bash <<< 'for code in {0..255}; do echo -n "[38;05;${code}m $(printf %03d $code)"; [ $((${code} % 16)) -eq 15 ] && echo; done' | |
elif [ "$target_shell" = "zsh" ]; then | |
zsh <<< 'for code in {000..255}; do print -nP -- "%F{$code}$code %f"; [ $((${code} % 16)) -eq 15 ] && echo; done' | |
else | |
echo "error: Invalid argument ($target)" | |
echo "Usage: $0 [bash|zsh]" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment