mirror of https://gitlab.com/ceda_ei/wish
Add RGB support to wish_append
This commit is contained in:
parent
4df41a68db
commit
d5049db176
14
wish.sh
14
wish.sh
|
@ -32,14 +32,28 @@ function wish_append() {
|
||||||
local text=$3
|
local text=$3
|
||||||
if [[ $fg_code -eq -1 ]]; then
|
if [[ $fg_code -eq -1 ]]; then
|
||||||
local fg="\[\033[0;5;0m\]"
|
local fg="\[\033[0;5;0m\]"
|
||||||
|
else
|
||||||
|
if [[ ${#fg_code} -eq 6 ]]; then
|
||||||
|
local r=$(( 16#${fg_code[0]}${fg_code[1]} ))
|
||||||
|
local g=$(( 16#${fg_code[2]}${fg_code[3]} ))
|
||||||
|
local b=$(( 16#${fg_code[4]}${fg_code[5]} ))
|
||||||
|
local fg="\[\033[38;2;$r;$g;${b}m\]"
|
||||||
else
|
else
|
||||||
local fg="\[\033[38;5;${fg_code}m\]"
|
local fg="\[\033[38;5;${fg_code}m\]"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if [[ $bg_code -eq -1 ]]; then
|
if [[ $bg_code -eq -1 ]]; then
|
||||||
local bg="\[\033[0;5;0m\]"
|
local bg="\[\033[0;5;0m\]"
|
||||||
|
else
|
||||||
|
if [[ ${#bg_code} -eq 6 ]]; then
|
||||||
|
local r=$(( 16#${bg_code[0]}${bg_code[1]} ))
|
||||||
|
local g=$(( 16#${bg_code[2]}${bg_code[3]} ))
|
||||||
|
local b=$(( 16#${bg_code[4]}${bg_code[5]} ))
|
||||||
|
local bg="\[\033[38;2;$r;$g;${b}m\]"
|
||||||
else
|
else
|
||||||
local bg="\[\033[48;5;${bg_code}m\]"
|
local bg="\[\033[48;5;${bg_code}m\]"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if [[ $fg_code -eq -1 ]]; then
|
if [[ $fg_code -eq -1 ]]; then
|
||||||
PS1="$PS1$fg${bg}$text"
|
PS1="$PS1$fg${bg}$text"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue