2009-10-02 29 views
9

視頻顯示問題: http://www.mentaframework.org/download/TerminalBug.movMac Terminal.app惱人的bug - 如何解決它?

當我打字的Terminal.app並達到行的結束,下一行開始在第一行的頂部,覆蓋一切。然後,如果我使用刪除鍵,一切都會消失。

我在同一個終端上做了一個ssh到不同的主機,它工作正常,所以它可能是我的shell配置的問題?

觀看電影,看看會發生什麼:

感謝,

-Sergio

+0

嗨塞爾吉奧。 http://superuser.com你可能會有更好的運氣。 – 2009-10-02 20:52:02

+1

視頻是一個斷開的鏈接。 – 2013-11-30 16:40:38

回答

18

您需要標記您的PS1變量的轉義碼被設置你的顏色提示。外殼需要知道它們不可打印,然後它會正確計算您的換行。

下面就來解釋的鏈接和一些例子:

http://www.artemfrolov.com/articles/coloured-bash-prompt

快速提示:

\[  begins a sequence of non-printing characters 
\]  ends a sequence of non-printing characters 
+0

這樣做!非常感謝! – TraderJoeChicago 2009-10-02 21:46:28

+0

沒問題。樂於幫助。 – 2009-10-02 21:50:36

+0

網址中斷 – 2015-05-27 12:27:53

1

http://www.artemfrolov.com/articles/coloured-bash-prompt目前是空白的(如,請在Chrome /火狐/歌劇只看到空白,沒有內容)。因此,研究的例子here後,我發現轉換:

export PS1='\e[0;32m\[email protected]\h\e[m \D{%b %d} \t $ ' 

打破,以

export PS1='\[\e[0;32m\]\[email protected]\h\[\e[m\] \D{%b %d} \t $ ' 

似乎爲我工作(作爲一個額外的,具體的例子)。

另外,稍微偏離主題,但有用的(至少我參考):上面的升級有幫助的「壓縮通道」並加粗綠色用戶@主機提示:

export MYPS='$(echo -n "${PWD/#$HOME/~}" | awk -F "/" '"'"'{if (length($0) > 14) { if (NF>4) print $1 "/" $2 "/.../" $(NF-1) "/" $NF; else if (NF>3) print $1 "/" $2 "/.../" $NF; else print $1 "/.../" $NF; } else print $0;}'"'"')' 
export PS1='\[\e[1;32m\]\[email protected]\h\[\e[m\] \D{%b %d} \t $(eval "echo ${MYPS}")$ ' 

**編輯**:這個PS1任務(第二行),imo,更容易閱讀:

export MYPS='$(echo -n "${PWD/#$HOME/~}" | awk -F "/" '"'"'{if (length($0) > 14) { if (NF>4) print $1 "/" $2 "/.../" $(NF-1) "/" $NF; else if (NF>3) print $1 "/" $2 "/.../" $NF; else print $1 "/.../" $NF; } else print $0;}'"'"')' 
export PS1='[email protected]\[$(tput bold)\]$(hostname -s)\[$(tput sgr0)\] \D{%b %d} \t $(eval "echo ${MYPS}")$ ' 
+0

爲什麼我會收到上述的倒計時? – 2015-04-27 21:13:39