rwxrob-dot/scripts/hex2rgb
Rob Muhlestein 2ea0289e9f Rebase
2022-02-09 02:29:05 -05:00

18 lines
347 B
Bash
Executable File

#!/usr/bin/env bash
rgb () {
declare g
declare b
case ${#1} in
6) r=$"0x${1:0:2}"; g=$"0x${1:2:2}"; b=$"0x${1:4:2}";;
3) rgb "${1:0:1}${1:0:1}${1:1:1}${1:1:1}${1:2:1}${1:2:1}"
return;;
1) rgb "$1$1$1"; return;;
*) return 1;;
esac
#printf '\033[38;2;%i;%i;%im' $r $g $b
printf "%i;%i;%i\n" $r $g $b
}
rgb $*