Bash terminal not wrapping text correctly [duplicate]
This seems somewhat related:
Wrapping the
tput
output in\[ \]
is recommended by the Bash man page. This helps Bash ignore non-printable characters so that it correctly calculates the size of the prompt.
Source.
"The tput
output" in your case looks like this: \e[1;35m
, \e[0;35m
(there are two separate fragments to wrap). They could be written as \033[1;35m
and \033[0;35m
as well. In general you need to wrap any non-printable sequence.
I modified your PS1
:
export PS1='\[\e[1;35m\][\u:\w]\$\[\e[0;35m\] '
and it seems to work for me without the issue.