KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a specific method for my bash prompt, let's say it looks like this: CHAR="༇ " my_function=" prompt=\" \[\$CHAR\]\" echo -e \$prompt" PS1="\$(${my_function}) \$ " To explain the above, I'm builidng my bash prompt by executing a function stored in a string, which was a decision made as the result of this question . Let's pretend like it works fine, because it does, except when unicode characters get involved I am trying to find the proper way to escape a unicode character, because right now it messes with the bash line length. An easy way to test if it's broken is to type a long command, execute it, press CTRL-R and type to find it, and then pressing CTRL-A CTRL-E to jump to the beginning / end of the line. If the text gets garbled then it's not working. I have tried several things to properly escape the unicode character in the function string, but nothing seems to be working. Special characters like this work: COLOR_BLUE=$(tput sgr0 && tput setaf 6) my_function=" prompt="\\[\$COLOR_BLUE\\] \" echo -e \$prompt" Which is the main reason I made the prompt a function string. That escape sequence does NOT mess with the line length, it's just the unicode character.
Tags (comma-separated)
Save Edits
Cancel