Skip to content
koalaman edited this page Feb 21, 2014 · 6 revisions

Make sure all escape sequences are enclosed in [..] to prevent line wrapping issues

Problematic code:

PS1='\e[36m\$ \e(B\e[m'

Correct code:

PS1='\[\e[36m\]\$ \[\e(B\e[m\]'

Rationale:

Bash is unable to determine exactly which parts of your prompt are text and which are terminal codes. You have to help it by wrapping invisible control codes in \[..\] (and ensuring that visible characters are not wrapped in \[..\]).

Note: ShellCheck offers this as a helpful hint and not a robust check. Don't rely on ShellCheck to verify that your prompt is correct.

Contraindications

None.

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally