pio*_*kkr 5 colors bash prompt terminal
我想列出可以在 bash 控制台中使用的所有颜色。之后我想将提示设置为粗体和类似橙色的颜色。我用它来为我列出颜色代码:
for code in {0..255}; do echo -e "\e[38;05;${code}m $code: Test"; done
Run Code Online (Sandbox Code Playgroud)
但问题是如何让它加粗并保持颜色呢?
我在这里寻找了一些关于将其设置为粗体的建议:http://misc.flogisoft.com/bash/tip_colors_and_formatting,但我找不到任何结合粗体和 256 种颜色之一的代码。
您可以将其写为以下任何一种:
echo -e "\e[1;38;05;${code}m $code: Test"
echo -e "\e[1m\e[38;05;${code}m $code: Test";
echo -e "\e[38;05;${code}m\e[1m $code: Test";
echo -e "\e[38;05;${code};1m $code: Test";
tput bold; tput setaf "$code" # provided the terminfo database is
# properly populated
Run Code Online (Sandbox Code Playgroud)
tput bold如果您不使用或或重置粗体,则只能运行一次。tput sgr0\e[m\e[0m