5

I have a random problem which I personally find quite irritating. I use the terminal alot and have installed a theme and even toyed around with what is displayed on the prompt. However if I write a particularly line of text it does not start a new line in the terminal instead it will begin overwriting what is displayed on the screen in the current terminal line. I wondered if anyone knew a way to solve this so that it does show a new line and all input would be visible.

PS1 value

export PS1="\r\n\e[1;32mdave:\w $\e[0;37m " 
2
  • 1
    What is the value of your customize PS1 variable? Commented Jul 14, 2013 at 9:59
  • export PS1="\r\n\e[1;32mdave:\w $\e[0;37m " Commented Jul 14, 2013 at 10:00

2 Answers 2

8

Well, thanks to the post by @Joni, I believe the solution is:

PS1="\r\n\[\e[1;32m\]dave:\w $\[\e[0;37m\] " 

That is, here the color codes \e[1;32m and \e[0;37m are enclosed within \[ and \], as @Joni suggested they should be.

Sign up to request clarification or add additional context in comments.

2 Comments

An error I make all the time when modifying my prompt. Thanks!
awesome sir! :D
4

Non printing characters, like escape codes for color, have to be surrounded with \[ and \] so that bash knows to exclude them when calculating the length of the line.

http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/nonprintingchars.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.