如何更改 zsh 中提示的颜色(与普通文本不同)? [英] How can I change the color of my prompt in zsh (different from normal text)?

查看:59
本文介绍了如何更改 zsh 中提示的颜色(与普通文本不同)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了更好地识别命令行上输出的开始和结束,我想更改提示的颜色,使其与程序输出明显不同.当我使用 zsh 时,谁能给我一个提示?

To recognize better the start and the end of output on a commandline, I want to change the color of my prompt, so that it is visibly different from the programs output. As I use zsh, can anyone give me a hint?

推荐答案

下面是一个如何设置红色提示的例子:

Here's an example of how to set a red prompt:

PS1=$'e[0;31m$ e[0m'

神奇的是 e[0;31m(打开红色前景)和 e[0m(关闭字符属性).这些被称为转义序列.不同的转义序列会给您不同的结果,从绝对光标定位到颜色,再到能够更改窗口的标题栏等等.

The magic is the e[0;31m (turn on red foreground) and e[0m (turn off character attributes). These are called escape sequences. Different escape sequences give you different results, from absolute cursor positioning, to color, to being able to change the title bar of your window, and so on.

有关转义序列的更多信息,请参阅有关 ANSI 转义码的维基百科条目

For more on escape sequences, see the wikipedia entry on ANSI escape codes

这篇关于如何更改 zsh 中提示的颜色(与普通文本不同)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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