损坏的行在sshterminal显示

我有我的控制台绘制线问题。 问题是,当我通过SSH连接到服务器,一切都画好了。 但是当我使用箭头键来显示上次使用的命令时,经常会在$ sign之后留下几个字符(粗体字是在提示符之后):

 user @ host:/ var / www_vhosts / instalator-paczek $ cp -r inst nano / etc / issue

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

 / 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

我不能使用任何长的命令,因为它覆盖开始,我不能看到,如果我input正确的一切。 在控制台内粘贴的长命令即使在显示已损坏的情况下也能正常工作。 这就像只有显示器被损坏,但命令本身是好的。

我有Ubuntu 12.10和Konsole作为terminal应用程序。 在服务器上有Debian GNU Linux 6.0

它只发生在这台服务器上,我连接的其他服务器,与Konsole一起工作良好。 我的同事使用putty连接到同一台服务器,他们也有同样的问题。 所以这似乎是问题是与服务器而不是terminal程序。

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

我需要补充的是,似乎调整控制台窗口也改变了服务器上的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 

我试过已经有解决scheme,包括使用resizereset命令,但他们没有帮助。

如何解决这个问题?

我已经在Unix和Linux上提出了相同的问题,但没有find解决scheme,所以我在这里写。

好了,我终于find解决办法 问题是$PS1没有用\[\]括起来的颜色序列。 在修正$PS1之前是:

 export PS1='\e[1;32m\u@\h:\w$ \e[m' 

修复后:

 export PS1='\[\e[1;32m\]\u@\h:\w$ \[\e[m\]' 

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

这里有几个问题。 上下箭头的问题通常来自术语types不匹配。

包装错误发生在我身上,通常是因为你改变了屏幕尺寸。 从“80×24”到“151×57”。 有时不设置LINES和ROWS可以解决问题,使用

 unset LINES unset ROWS 

然后看看问题是否消失。 有命令(我认为stty可以做到这一点),这将重置你的terminal后,你调整它,使bash不会吓坏了,但我不得不去看看它。