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

前端 未结 10 1887
醉梦人生
醉梦人生 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:27

    I have found that, with zsh5 (the default one on Debian Jessie), all those solutions works:

    • $'\e[00m
    • $fg[white]
    • $fg{white}

    Now, they have a problem: they will move the cursor, resulting in ugly decal when tabbing (for auto-completion). The solution is simply to surround the escape sequences with %{FOOBAR%}. Took me a while to figure this. For 2nd and 3rd solutions loading colors module is mandatory. To keep the 1st solution readable, just define variables for the colors you use.

提交回复
热议问题