如何在控制台中使用 ANSI 转义序列将斜体或粗体等格式应用于文本?
How do I apply formatting like italic or bold to text using ANSI escaping sequences in a console?
如何使用 ANSI 转义格式化文本?
喜欢制作 斜体 或 粗体 以及删除线和超级脚本。
如何使用 ANSI 终端转义码将内容设置为斜体或粗体?
粗体:使用ESC[1m
不支持斜体、删除线和上标。
一些终端支持额外的序列。例如,在 Gnome 终端中,您可以使用:
echo -e "\e[1mbold\e[0m"
echo -e "\e[3mitalic\e[0m"
echo -e "\e[4munderline\e[0m"
echo -e "\e[9mstrikethrough\e[0m"
echo -e "\e[31mHello World\e[0m"
echo -e "\x1B[31mHello World\e[0m"
来源How to do: underline, bold, italic, strikethrough, color, background, and size in Gnome Terminal?, answer by Sylvain Pineau
进一步阅读
如何使用 ANSI 转义格式化文本?
喜欢制作 斜体 或 粗体 以及删除线和超级脚本。
如何使用 ANSI 终端转义码将内容设置为斜体或粗体?
粗体:使用ESC[1m
不支持斜体、删除线和上标。
一些终端支持额外的序列。例如,在 Gnome 终端中,您可以使用:
echo -e "\e[1mbold\e[0m" echo -e "\e[3mitalic\e[0m" echo -e "\e[4munderline\e[0m" echo -e "\e[9mstrikethrough\e[0m" echo -e "\e[31mHello World\e[0m" echo -e "\x1B[31mHello World\e[0m"
来源How to do: underline, bold, italic, strikethrough, color, background, and size in Gnome Terminal?, answer by Sylvain Pineau