3

I have problem with my console drawing lines. The problem is when I connect through ssh to server everything draws ok. But when I use up arrow key to show last used commands it often leaves few characters after $ sign like (in bold is what stays after the prompt):

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

What is even more irritating is what happens when I type more characters than console width. Cursor somehow goes back to the beginning of line and overwrites prompt:

/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

I can't use any long commands because it overwrites beginning and I can't see if I typed everything correctly. Long command when pasted inside console works even if display is corrupted. It's like only display is corrupted but command itself is ok.

I have ubuntu 12.10 and use Konsole as terminal application. On server there is Debian GNU Linux 6.0

It only happens with this server other servers I connect, works good with Konsole. My coworkers use putty to connect to same server and they also have same problem. So it seem like problem is with server not terminal program.

On server there is no xterm package so I fought that it should install it to fix the problem. But even after I've installed this package same problem exists. Should I restart server after installing xterm? I prefer not to because I'm not server admin.

I need to add that it seems like resizing console window also changes stty on server:

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

I tried already solutions including using resize and reset commands but they didn't help.

How to fix this?

I've asked same question on Unix & Linux but no solution found, so I'm writing here.

piotrekkr
  • 226
  • 2
  • 9

2 Answers2

5

OK finally I found solution. The problem was that $PS1 didn't have color sequences enclosed with \[ and \]. Before correcting $PS1 was:

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

after fix:

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

I found solution here: https://stackoverflow.com/questions/2024884/commandline-overwrites-itself-when-the-commands-get-to-long

piotrekkr
  • 226
  • 2
  • 9
0

There are a few issues here. The problem with the up and down arrows usually comes from the term types being mismatched.

The wrap error happens to me, it is usually because you changed the screen size. From "80x24" to "151x57". Sometimes unsetting LINES and ROWS can fix the problem, use

unset LINES
unset ROWS

and then see if the problem goes away. There is command (I think stty can do it as well), that will reset you terminal after you resize it so that bash doesn't freak out, but I'd have to go look it up.

Walter
  • 1,047
  • 7
  • 14
  • I've tried `reset` and `resize` commands but problem is the same. It happens also just after I log into server. I don't need to resize terminal window to get those problems. I'll try `unset` once I get to work – piotrekkr Jun 07 '13 at 06:19
  • I've tried `unset` but it didn't work. As I mentioned in my question `stty` show correct width and height after terminal resize without using `reset` `resize` `unset` etc. – piotrekkr Jun 07 '13 at 08:04