命令行提示符參數PS1, 但是不會自動換行

在設置命令行提示符的字體顏色之後,輸入超過一行的命令時會覆蓋當前行內容,不能自動換行。問題原因是命令提示符中有控制字符(如字體顏色),它需要使用 \[\]包圍。

以下摘抄自bash的manpage中PROMPTING一節

\[     begin a sequence  of  non-printing  characters,  which
       could  be  used  to  embed a terminal control sequence
       into the prompt
\]     end a sequence of non-printing characters

參考文章:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章