#!/usr/bin/env bash
#
# 256 - print colors in 256 palette

# the bestest and fasterest 256 color script.
# Usage: 256 end_col ('256 16', '256 256' or '256')
# (c) Dylan Araps
i=0
while [ "${i}" -lt "${1:-256}" ]; do
  i=$((i + 1))
  printf '%s\e[4D\e[4C\e[48;5;%sm\e[K\e[m\n' "${i}" "${i}"
done

# see: https://github.com/kiedtl/bin/blob/master/256
# e="$(printf "\033")"
# t="Lorem \033[1mipsum."
# f256() {
#   i=$1
#   while [ "${i}" -le 255 ]; do
#     printf "${i}${e}[4D${e}[4C"
#     printf "${e}[38;5;${i}m ${t} ${e}[0m "
#     printf "${e}[48;5;${i}m${e}[30m ${t} ${e}[0m "
#     printf "${e}[48;5;${i}m ${t} ${e}[0m "
#     printf "${e}[48;5;${i}m${e}[K${e}[m\n"
#     i=$((i + 1))
#   done
# }
# if [ -z "${1}" ]; then
#   f256 0
# else
#   f256 "${1}"
# fi
