BASH, PS1 and the long commands
Written by
oscarmlage
on
Had a strange behavior in my bash while browsing the command history. I'm always traveling in time with the <Up>
arrow in my bash, but when a long command (longer than $COLUMNS) is being loaded, the prompt ($PS1) dissapears and it starts to behave as hell:
After some reserach here and there, as usual, StackOverflow gave me the answer: the unenclosed non-printable character sequences:
In my case it was exactly like that:
export PS1="033[1;30m]» [e[0;33m]mbp033[1;30m]╺─╸[033[1;30m][[033[0m]W[033[1;30m]][033[1;34m]:[033[0m] "
export PS1="[033[1;30m]» [e[0;33m]mbp[033[1;30m]╺─╸[033[1;30m][[033[0m]W[033[1;30m]][033[1;34m]:[033[0m] "
Could you spot the difference?. Please ensure all your non-printable sequences are enclosed in [
and ]
in your prompt before complain about bash doing weird things.