如何更改我的提示在zsh(不同于正常文本)的颜色? [英] How can I change the color of my prompt in zsh (different from normal text)?

查看:509
本文介绍了如何更改我的提示在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天全站免登陆