0
在使用git時,我決定將.git-prompt.sh添加到我的.bashrc文件中。該文件顯示了我目前正在使用的分支的名稱。 我也決定添加一些顏色。終端顏色導致提示跳回到行的開頭
if [ -f ~/.git-prompt.sh ]; then
#include the branch detection file
source ~/.git-prompt.sh
#add the current branch in yellow
export PS1='$(__git_ps1 "[\e[38;5;220m%s\x1b[0m]")'
#make the rest of the text in the prompt gray
PS1+="\e[38;5;245m\w$ "
#set colors back to default
PS1+="\033[0m"
fi
使用任何終端(gnome-terminal,xterm,quake)都會導致同樣的問題。當輸入了一行變得很長,
迅速跳回行的開頭。這可能是因爲彩色文字的實際長度更長。
我如何得到終端的顏色沒有這個打嗝?
這解決了我的問題,因爲終端提示現在正確移動。 –