How can I change the color of my prompt in zsh (different from normal text)?

前端 未结 10 1916
醉梦人生
醉梦人生 2020-12-07 07:34

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

10条回答
  •  我在风中等你
    2020-12-07 08:05

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

    PS1=$'\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.

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

提交回复
热议问题