Created
April 27, 2021 07:14
-
-
Save nberlette/b5ecf3d74d11c777d50128d38a6bfd3a to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
# hex2bash.sh | |
# rudamentary bash function to format hex colors into RGB form | |
# and output them as xterm-256color esc-code, with samples :D | |
# 2021 Nick Berlette | |
# https://github.com/nberlette | |
function hex2bash { | |
local hex=${1/'#'/''} | |
local rgb=$(printf "%d;%d;%d" 0x${hex:0:2} 0x${hex:2:2} 0x${hex:4:2}) | |
echo -e "\e[38;2;${rgb}m \\\e[38;2;${rgb}m \e[0m \b\e[48;2;${rgb};38;2;0;0;0m \\\e[48;2;${rgb}m \e[0m\n" | |
} | |
# Usage: | |
hex2bash "$1" |
Author
nberlette
commented
Apr 27, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment