Re:Do not use redirection characters in your shell prompt
by afesfsfresfr on Wednesday March 17, 2021 @01:38PM
(#26494453)
I remember independently inventing the ": foo;" prompt, and using it with Bash, in the late 90s. My beard is gray now.
It's not really practical because there are all sorts of values of "foo" which will make Bash choke when it tries to evaluate the string. Backticks and parentheses, for example, will cause problems, as will newlines (which NB may even occur in filenames, along with other problematic characters!). So the "foo" string typically needs to be sanitized using an external command: https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x279.html
Once you get to that point the idea no longer seems as elegant.
It's not really practical because there are all sorts of values of "foo" which will make Bash choke when it tries to evaluate the string. Backticks and parentheses, for example, will cause problems, as will newlines (which NB may even occur in filenames, along with other problematic characters!). So the "foo" string typically needs to be sanitized using an external command: https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x279.html
Once you get to that point the idea no longer seems as elegant.