ssh 终端中显示损坏的行

pio*_*kkr 3 debian ssh console display

我的控制台画线有问题。问题是当我通过 ssh 连接到服务器时一切正常。但是当我使用向上箭头键显示上次使用的命令时,它通常会在$符号后留下几个字符(粗体是提示后的内容):

用户@主机:/var/www_vhosts/instalator-paczek$ cp -r inst nano /etc/issue

更令人恼火的是,当我输入的字符数超过控制台宽度时会发生什么。光标以某种方式回到行首并覆盖提示:

/d/asd/as/d/asd/asd/as/d/asd/asd ww_vhosts/instalator-paczek$ ls -la asdkasdasdasd/asdasdasd/asdasdasdasdasdas/dasdsdaas/d/asd/as/d/asd/as

我不能使用任何长命令,因为它会覆盖开头,而且我看不到我是否正确输入了所有内容。即使显示已损坏,粘贴到控制台内的长命令也能正常工作。就像只有显示损坏了,但命令本身没问题。

我有 ubuntu 12.10 并Konsole用作终端应用程序。在服务器上有Debian GNU Linux 6.0

它只发生在这个服务器上我连接的其他服务器上,与Konsole. 我的同事使用putty连接到同一台服务器,他们也有同样的问题。所以看起来问题出在服务器而不是终端程序上。

在服务器上没有xterm包,所以我争取它应该安装它来解决问题。但即使在我安装了这个包之后,同样的问题仍然存在。安装后我应该重新启动服务器xterm吗?我不想这样做,因为我不是服务器管理员。

我需要补充一点,调整控制台窗口的大小似乎也在stty服务器上发生了变化:

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
Run Code Online (Sandbox Code Playgroud)

我已经尝试过包括使用resizereset命令在内的解决方案,但它们没有帮助。

如何解决这个问题?

我在Unix 和 Linux上问过同样的问题,但没有找到解决方案,所以我写在这里。

pio*_*kkr 5

好吧,我终于找到了解决方案。问题是$PS1没有用\[和括起来的颜色序列\]。更正前$PS1是:

export PS1='\e[1;32m\u@\h:\w$ \e[m'
Run Code Online (Sandbox Code Playgroud)

修复后:

export PS1='\[\e[1;32m\]\u@\h:\w$ \[\e[m\]'
Run Code Online (Sandbox Code Playgroud)

我在这里找到了解决方案:https : //stackoverflow.com/questions/2024884/commandline-overwrites-itself-when-the-commands-get-to-long