如何在 zsh 提示中斜体文本? [英] How to italicise text in zsh prompt?

查看:30
本文介绍了如何在 zsh 提示中斜体文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力理解如何将我的 zsh 提示的一部分设为斜体(使用 prezto).

I'm struggling to understand how to italicise a section of my zsh prompt (using prezto).

我的提示目前看起来像这样:

My prompt currently looks like this:

PROMPT='%F{yellow}%T %F{magenta}${SSH_TTY:+%n@%m }%F{cyan}%1~%f${vcs_info}\55 %(!.%B%F{red}#%f%b.%B %(?.%F{green}.%F{red})❯%f%b) '

假设我想将 vcs_info 设为斜体,我该怎么做?

Say I wanted to make the vcs_info italic, how would I do that?

推荐答案

理论上,ANSI 转义码 \e[3m 设置斜体 SGR.因此,要回答您的问题,这应该可行:

In theory, the ANSI escape code \e[3m sets the italic SGR. So to answer your question, this should work:

PROMPT='...%{\x1b[3m%}${vcs_info}%{\x1b[0m...%}'

不幸的是,斜体文本在终端模拟器中没有得到广泛支持.有些只是忽略它,有些则反转颜色而不是斜体文本.要测试您的终端模拟器,请检查 echo -e "\e[3mitalic\e[0m" 的输出.如果这不打印italic,您需要使用可以打印的终端模拟器,例如 gnome-terminal.

Unfortunately, italic text is not widely supported in terminals emulators. Some just ignore it, others inverse the colors instead of italicizing text. To test your terminal emulator, check the output of echo -e "\e[3mitalic\e[0m". If that doesn't print italic, you need to use a terminal emulator that does, such as gnome-terminal.

这篇关于如何在 zsh 提示中斜体文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆