I'm using ssh command from osx terminal to connect my centos remote server. If I type long string and want to go next line, the characters don't go to second line but come back the first line left side. And they overwrap prompt strings.

For example, I want to type like this.

[username@hostname ~] loooooooooooong command and the arguments that come

to second line

But it ends up like this.

to second linename ~] loooooooooooong command and the arguments that come

Is there way to avoid this over-wrapping?

2 Answers 2


That usually happens if the prompt contains non-printing characters that are not surrounded with \[ and \].

So for example use PS1='\[\e[33;1m\]\W\[\e[m\] ' instead of PS1='\e[33;1m\W\e[m '.

  • Thanks! I was used like `GREEN="0;32" START_COLOR="\e[${GREEN}m" END_COLOR="\e[0m" PS1="${START_COLOR}[\u@SakuraVPS \W$]${END_COLOR}]"
    – ironsand
    Sep 23, 2013 at 4:43
  • I rewrite is like GREEN="0;32" START_COLOR="\e[${GREEN}m" END_COLOR="\e[0m" PS1="\[${START_COLOR}\u@SakuraVPS \W$ ${END_COLOR}\]", then over-wrapping is solved. But another problem happens, when I hit a character and delete the charactor, then the prompt strings also deleted. why is that happens?
    – ironsand
    Sep 23, 2013 at 4:54

I have this happen occasionally and the reset command (run on the remote host) usually brings back wrapped lines for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.