That's not valid bash
escape syntax for simple double quotes. Try instead
PS1=$'\xe2\x98\xa2 '
This uses the special $'...'
quoting that bash
has and which does support ANSI C escapes. Note that the 0a
is just linefeed (newline character) and I doubt you want that, so I took the liberty of replacing it with a space above.
Of course, instead of going through the entire rigamarole of finding the UTF-8 encoding, and then typing out the escapes, you could just use the raw character itself (PS1='☢ '
) and it would still work.
Non-printable sequences should be enclosed in \[
and \]
. Looking at your PS1 it has a unenclosed sequence after \W
. But, the second entry is redundant as well as it repeats the previous statement "1;34".
\[\033[01;32m\]\u:\[\033[01;34m\] \W\033[01;34m \$\[\033[00m\]
|_____________| |_|
| |
+--- Let this apply to this as well.
As such this should have intended coloring:
\[\033[1;32m\]\u:\[\033[1;34m\] \W \$\[\033[0m\]
|_____|
|
+---- Bold blue.
Keeping the "original" this should also work:
\[\033[1;32m\]\u:\[\033[1;34m\] \W\[\033[1;34m\] \$\[\033[0m\]
|_| |_|
| |
+-----------+-- Enclose in \[ \]
Edit:
The reason for the behavior is because bash
believes the prompt is longer then it actually is. As a simple example, if one use:
PS1="\033[0;34m$"
1 2345678
The prompt is believed to be 8 characters and not 1. As such if terminal window is 20 columns, after typing 12 characters, it is believed to be 20 and wraps around. This is also evident if one then try to do backspace or Ctrl+u. It stops at column 9.
However it also does not start new line unless one are on last column, as a result the first line is overwritten.
If one keep typing the line should wrap to next line after 32 characters.
Best Answer
If you're like me and you MUST have the emoji in your prompt, this fixed the line wrap problem for me:
Essentially, this makes the lightning bolt not be counted in the prompts length, better explained in this askubuntu thread.