While modifying the definition of my PS1, I saw that "\[" and "\]" markers should be added to help bash to compute the right display lenght. Many exemples on the web do not use them or even mention them.
I searched for a solution to add them automatically, like with sed, but I didn't find any example.
Are they still needed and is there a recommandation not to use sed to define PS1?
This is what I use at the moment:
PS1="$(echo -n "$PS_" | sed -e 's/\\e\[/\\\[\\e\[/g' -e 's/[0-9]m/&\\\]/g')"