I am having trouble with my bash prompt and line wrapping behaviour. If I use a static prompt
export PS1="test$ "; ### Works perfectly
I can type long lines on the prompt and they wrap fine. Scroll up/down in history also work fine. On using dynamic prompt like:
export PS1="\u@\h(\W)$ "; ### Long lines don't wrap at all
long lines got scrambled. Found a fix that made long lines wrap correctly. (http://hintsforums.macworld.com/showthread.php?t=17068).
export PS1="\[\u@\h(\W)$ \]"; ### Long lines wrap while typing, but not while scrolling up/down through previous commands
However, when going up/down the prompt history, the lines do not wrap. I dont know how to explain the behaviour in words, but I will try - when I go up (up arrow key), half the last command is eaten up and cursor ends up somewhere in between where the line would have wrapped.
What is the solution for this?
I remember that on many linux distributions dynamic prompts work correctly out of the box (this is at my workplace).
regards,
JP