3 clarify the actual remedy
source | link

For multi-line prompts (including when it wraps, including from your commands), you need to enclose your color codes in an extra escapeenclose your color codes in escaped square brackets (like \[$color\]).

This example is green, has user@hostname:workingdir $ and then reverts back to uncolored:

PS1='\[\e[1;32m\]\u@\h:\w \$\[\e[0;0m\]'

For multi-line prompts (including when it wraps, including from your commands), you need to enclose your color codes in an extra escape.

This example is green, has user@hostname:workingdir $ and then reverts back to uncolored:

PS1='\[\e[1;32m\]\u@\h:\w \$\[\e[0;0m\]'

For multi-line prompts (including when it wraps, including from your commands), you need to enclose your color codes in escaped square brackets (like \[$color\]).

This example is green, has user@hostname:workingdir $ and then reverts back to uncolored:

PS1='\[\e[1;32m\]\u@\h:\w \$\[\e[0;0m\]'
2 added 141 characters in body
source | link

YouFor multi-line prompts (including when it wraps, including from your commands), you need to enclose your color codes in an extra escape just for your prompt, for.

This example is green, has user@hostname:workingdir $ and then reverts back to uncolored:

PS1='\[\e[1;32m\]\u@\h:\w\[\e[0;0m\] \$\w '\$\[\e[0;0m\]'

You need to enclose your color codes in an extra escape just for your prompt, for example:

PS1='\[\e[1;32m\]\u@\h:\w\[\e[0;0m\] \$ '

For multi-line prompts (including when it wraps, including from your commands), you need to enclose your color codes in an extra escape.

This example is green, has user@hostname:workingdir $ and then reverts back to uncolored:

PS1='\[\e[1;32m\]\u@\h:\w \$\[\e[0;0m\]'
1
source | link

You need to enclose your color codes in an extra escape just for your prompt, for example:

PS1='\[\e[1;32m\]\u@\h:\w\[\e[0;0m\] \$ '