Credit to these very helpful Internet sources:
- r/OutOfTheLoop: Where did the "༼ つ ◕_◕ ༽つ" emoticon get started?
- tldp: Bash Prompt HOWTO: ANSI Escape Sequences
- StackOverflow: A.D.'s answer to Custom Bash prompt is overwriting itself
The StackOverflow discussion, in particular, got me over the problem of the cursor position being screwed up (overlapping and overwriting the line) when doing escape sequences. Apparently you have to prepend \[
and append \]
around each escape sequence.