Bash prompt line wrapping issue

前端 未结 2 391
时光取名叫无心
时光取名叫无心 2021-01-11 18:50

Newbie question, I recently changed my PS1 into this:

RESET=\"\\[\\017\\]\"
NORMAL=\"\\[\\033[0m\\]\"
YELLOW=\"\\[\\033[0;33m\\]\"
CYAN=\"\\[\\033[0;36m\\]\"         


        
2条回答
  •  长发绾君心
    2021-01-11 19:43

    The wrapping error occurs whenever a non-printing character is not escaped (such as the escape codes that change the prompt color). It also occurs when the locale is set to something that does not understand unicode characters and the prompt includes them. An example would be non-breaking spaces. When the locale is "C" and there are unicode characters in the prompt, the shell thinks more characters are being printed than truly are, and the prompt wraps around prematurely.

提交回复
热议问题