After several frustrations I decided to share it so that next time I don't have to refer to my notebook but Google for it.
Is there some definitive documentation for PS1 strings accepted values?
- escape letters
- colors
- Unicode chars
After several frustrations I decided to share it so that next time I don't have to refer to my notebook but Google for it.
Is there some definitive documentation for PS1 strings accepted values?
\[
and end with\]
.\x+hex_value
, we can add Unicode chars into PS1 strings. How to find out Unicode of any char/string? Useecho <char> | hexdump -C
. arg can be a string. The0a
at the end represents a new line. Because bash works on base of line buffer; must flush to know that this string is terminated. If you want to insert any character in a prompt string, delete every0a
except the last one, if needed.For example:
So, you can insert the character in ps like:
I found that with the converted string of Chinese characters,
echo -e
andprintf
both works expected, outputs the Chinese character, but in$PS1
it fails. So I was forced to assign a variable to the value of the commandecho -e string
orprintf string
.This works well.