So recently I updated my bash prompt to be a little easier on my eyes, however, after I was done for some reason if I typed in long commands they would not automatically wrap to the next line, it would just overwrite the current line. This made things a little interesting..hah
Here’s my new prompt, (which had the problem..)
export PS1="\e[32m[\@] \u@\h:\e[33m\w \e[32m\$ "
[11:16 PM] phatdee@thebeaver:/tmp $
To fix this, you need to do this, you need to wrap each escape section using [\ \]. This is needed so that readline will be able to correctly evaluate the where the margin ends thus automatically switching to the new line and not just writting over the same line. I’m sure this can be explained a little better but hopefully you get it. Here’s the working PS1 line, pay special attention to the 4 new [\ \] , two for each escape (\e) section.
Also instead of switching to the “green” color in the above which is escape 32m, I just reset the color back to the original to do that, just use \e[0m
export PS1="[\@] \u@\h:\[\e[1;33m\]\w\[\e[0m\] $ "
[12:24 AM] phatdee@thebeaver:/var/tmp $
Some syntax help:
\@ = does the time in 12H mode
\u = username of logged in user ($LOGNAME)
\h = hostname
\w = current directory
\e[1;33m = yellow text
\e[0m = resets text to original
I use terminator for my terminal client, and often have multiple windows open with different sizes. I was finding that sometimes my window would not word wrap no matter what I did. However after turning this on, I no longer had that issue.
$ shopt | grep checkwinsize
If this is off, try turning this on
$ shopt -s checkwinsize
Add this to your .bashrc if you find it working.