[TriLUG] Changing slashes to backslashes in prompt

Casey Ransom via TriLUG trilug at trilug.org
Fri Apr 19 17:54:12 EDT 2019


As an exercise, it is definitely rigorous because dealing with the prompt
and any number of escapes for the slashes is maddening and even when right,
it looks like gibberish.

But for feedback on your solution itself, I'd recommend to see if you can
rewrite the string without resorting to echo and a pipe to sed because bash
has it's own string manipulation that's way faster than shelling out.
https://www.tldp.org/LDP/abs/html/parameter-substitution.html

It may not work in a shell prompt (it didn't for me just adding it to PS1,
but it would be fine in any other script you may use). You can run
'ZWNobyAke1BXRC8vXC8vXFx9Cg==' through a base64 decoder to see my solution,
in case you wanted to avoid spoilers.


More information about the TriLUG mailing list