Skip to content

Instantly share code, notes, and snippets.

@alpaca-tc
Created April 15, 2013 12:35
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 alpaca-tc/5387735 to your computer and use it in GitHub Desktop.
Save alpaca-tc/5387735 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# 256色のカラーパレットを表示する
# bash と zsh にて実行可能
#
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 "x27[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