color
时,支持随机颜色自动化。请将以下行添加到 ~/.profile
或 ~/.zshrc
中:PRELINE="\r\033[A"
function random {
echo -e "\033]6;1;bg;red;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
echo -e "\033]6;1;bg;green;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
echo -e "\033]6;1;bg;blue;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
}
function color {
case $1 in
green)
echo -e "\033]6;1;bg;red;brightness;57\a"$PRELINE
echo -e "\033]6;1;bg;green;brightness;197\a"$PRELINE
echo -e "\033]6;1;bg;blue;brightness;77\a"$PRELINE
;;
red)
echo -e "\033]6;1;bg;red;brightness;270\a"$PRELINE
echo -e "\033]6;1;bg;green;brightness;60\a"$PRELINE
echo -e "\033]6;1;bg;blue;brightness;83\a"$PRELINE
;;
orange)
echo -e "\033]6;1;bg;red;brightness;227\a"$PRELINE
echo -e "\033]6;1;bg;green;brightness;143\a"$PRELINE
echo -e "\033]6;1;bg;blue;brightness;10\a"$PRELINE
;;
*)
random
esac
}
#color #uncomment to enable automatically set random color when tab created
color
自动为其提供新的/随机颜色。color
添加到.zshrc
/ .profile
的末尾或者就在function color
之后。function tabcolor {
echo -n -e "\033]6;1;bg;red;brightness;$1\a"
echo -n -e "\033]6;1;bg;green;brightness;$2\a"
echo -n -e "\033]6;1;bg;blue;brightness;$3\a"
}
tabcolor $(jot -r 1 0 255) $(jot -r 1 0 255) $(jot -r 1 0 255)