我的控制台画线有问题。问题是当我通过 ssh 连接到服务器时一切正常。但是,当我使用向上箭头键显示上次使用的命令时,它通常会在$
符号后留下几个字符:
user@host:~$ cd /var/www_vhosts/
user@host:/var/www_vhosts$ ls -la instalator-paczek/
razem 16
drwxrwxr-x 3 root root 4096 02-20 10:48 .
drwxr-xr-x 13 root root 4096 05-17 11:11 ..
-rwxrw-r-- 1 root developers 3380 05-29 11:03 instalator-paczek.sh
drwxrwxr-x 2 user developers 4096 05-29 11:03 logi
user@host:/var/www_vhosts$ cd instalator-paczek/
user@host:/var/www_vhosts/instalator-paczek$ nano instalator-paczek.sh
user@host:/var/www_vhosts/instalator-paczek$ cp -r inst
user@host:/var/www_vhosts/instalator-paczek$ nano /etc/issue
user@host:/var/www_vhosts/instalator-paczek$ uname
Linux
user@host:/var/www_vhosts/instalator-paczek$ uname -a
Linux host 2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012 x86_64 GNU/Linux
user@host:/var/www_vhosts/instalator-paczek$ cat /etc/issue
Debian GNU/Linux 6.0 \n \l
# here I use up arrow key to display last used commands and everything is ok until it show last: "cp -r in..." command
# "cp -r inst" is shown and next last used commands are shown after those 10 characters. I displays them like:
# $ cp -r instls -la
# $ cp -r instcd directory
# etc.
# I tried using backspace but it clear characters just until "cp -r inst", not even one more
# prompt is shown correctly only after i press enter or ^C
user@host:/var/www_vhosts/instalator-paczek$ cp -r instnano /etc/issue
user@host:/var/www_vhosts/instalator-paczek$ ls
instalator-paczek.sh logi
更令人恼火的是,当我输入的字符多于控制台宽度时会发生什么。光标以某种方式返回到行首并覆盖提示:
/d/asd/as/d/asd/asd/as/d/asd/asdww_vhosts/instalator-paczek$ ls -la asdkasdasdasd/asdasdasd/asdasdasdasdasdas/dasdsdaas/d/asd/as/d/asd/as
我无法使用任何长命令,因为它会覆盖开头,而且我无法查看我是否正确输入了所有内容。即使显示损坏,粘贴到控制台内的长命令也可以工作。就像只有显示损坏但命令本身没问题。
我有 ubuntu 12.10 并用作Konsole
控制台应用程序。服务器上有Debian GNU Linux 6.0
xterm。
user@host:/var/www_vhosts/instalator-paczek$ echo $TERM
xterm
它只发生在这台服务器上,我连接的其他服务器运行良好Konsole
。
如何解决这个问题?
编辑
发生这些错误是否可能是因为服务器上没有xterm
安装并且没有调整大小命令?
user@host:~$ stty -a
speed 38400 baud; rows 57; columns 151; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
user@host:~$ stty -a
speed 38400 baud; rows 57; columns 172; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
似乎调整控制台窗口的大小也会发生变化stty
。
编辑2
我已经xterm
在服务器上安装了软件包。我已经注销并再次登录,但问题仍然相同。安装后我应该重新启动服务器xterm
吗?
编辑3
解决方案这里
答案1
答案2
好吧,我终于找到了解决方案。问题是$PS1
没有用 和 括起来的颜色\[
序列\]
。更正前$PS1
是:
export PS1='\e[1;32m\u@\h:\w$ \e[m'
修复后:
export PS1='\[\e[1;32m\]\u@\h:\w$ \[\e[m\]'
我在这里找到了解决方案:https://stackoverflow.com/questions/2024884/commandline-overwrites-itself-when-the-commands-get-to-long