2

I should preface this by saying this terminal session is via ssh from Windows PuTTY to Linux OpenSSH. I'm not sure if this matters, but I figured I should say it anyways.

Currently, when I write more in the terminal than fits on one line, the text begins on the same line rather than a new one, and causes my prompt to go from this:

trevor@SEARS-SERVER:~$

to this (example text of course):

ne lineSEARS-SERVER:~$ this is the text line that is too long to fit on o

Currently my PS1 is set up in my .bashrc with:

export PS1="\n[$(date +%r)] \e]0;\e[0;32m\u\e[m@\e[38;5;52m\h\e[m:\e[38;5;240m\w\e[m\e[97m$\e[m"

Also, when the windows is below a certain width, this happens:

m$ :32:40 PM] trevor@SEARS-SERVER:~

I know this has something to do with either my PS1 configuration, or PuTTY, but I don't know which, or why/how. Any help?

0

1 Answer 1

5

The problem is your prompt:

export PS1="\n[$(date +%r)] \e]0;\e[0;32m\u\e[m@\e[38;5;52m\h\e[m:\e[38;5;240m\w\e[m\e[97m$\e[m"

To make bash ignore the escape sequences (which are nonprinting), you have to bracket those with \[ and \].

Otherwise, bash counts those as part of the length of your prompt on the screen, and gets confused about when the terminal will autowrap to the next line.

Something like this would help:

export PS1="\n[$(date +%r)] \[\e]0;\e[0;32m\]\u\[\e[m\]@\[\e[38;5;52m\]\h\[\e[m\]:\[\e[38;5;240m\]\w\[\e[m\e[97m\]$\[\e[m\]"

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