2

So I'm having a really weird terminal problem that affects both physical login sessions as well as sessions over SSH. Basically, the terminal size is some number of columns. When printing stuff out, it'll properly use this amount of columns and wrap around when needed. However, when I'm typing in an actual command, it will use some smaller amount of columns. Probably 90 or 100 columns. At this point it'll wrap around to the current line (rather than the next time). If I start to backspace with a wrapped command, then when it gets to where it wraps back around the entire command line will instead change to a blank line. This behavior also happens when I push the up arrow key to repeat a previous command.

What exactly is going on here and how do I stop it?

It seems like making a new terminal session usually fixes it, but nothing else seems to including reset.

1
  • One tell-tale is a less-than sign at the start of the editing line or a greater than sign at the end. Are either of those appearing?
    – JdeBP
    May 25, 2015 at 18:34

2 Answers 2

2

I don't know how it works but running stty sane usually fixes those kind of terminal issues for me.

Shell Prompt

Given the description of your problem, I suspect that the issue may be related to your prompt. You have to be careful when setting prompts that include ANSI escape sequences that change colour, etc. Some of them cause bash to think the prompt takes up more space than it really does. See this really good Ask Ubuntu answer.

you have to tell Bash that that sequence of characters should not be counted in the prompt’s length, and you do that by enclosing it in (escaped) square brackets \[ \].

I also recommend using tput instead of hardcoding terminal escape sequences. See BashFAQ 53 and Terminal codes (ANSI/VT100) introduction for more.

2
  • Interesting... doing stty sane didn't help, but I'll have to look into the prompt escaping. I'm pretty sure I'm not following that
    – Earlz
    May 26, 2015 at 13:50
  • Hi @Earlz I was just wondering if you resolved this issue and was it related to non-printing characters in your prompt? Jun 10, 2015 at 15:21
0

IMO, if you have already done reset than there is really nothing much else you can do. Bite the bullet and start a new terminal session instead.

It basically happens to me when/after I wrongly cat the content of binary file to terminal. If it is beyond repair, then it is beyond repair.

4
  • I've seen the usual ruined terminal from catting a binary file, but this problem appears to happen much more often and not from doing that
    – Earlz
    May 26, 2015 at 13:50
  • In that case, which terminal software are you using? The reason I chose xterm is exactly to avoid un-handled end cases like these. My xterm has been quite robust, they are on 24x7, and rarely rarely I get into situation like this. I do reset for xterm less than once a year.
    – xpt
    May 26, 2015 at 17:45
  • BTW, to whom ever down vote this, please justify your action. Speak up! Tell us why you are doing it.
    – xpt
    May 26, 2015 at 17:49
  • it happens through both SSH using various terminal emulators (at least 3 tried and exhibits the problem) and through the xfce-terminal program
    – Earlz
    May 26, 2015 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .