Recently, I had to change the color of the prompt when I enter a specific directory and, back to default prompt color when I leave a specific directory.
To change the color of the prompt when enter a specific directory, I used a combination of direnv
and .envrc
. In .envrc
, I changed the color of the prompt with the following code.
export PROMPT='%S%F{magenta}${PWD##$(git rev-parse --show-toplevel)/} PROD%f%s ➤ '
There was no problem with entering a specific directory and changing the color of prompt, but now when I exit this folder (eg cd ../
), I realized that the prompt color does not return to its default color.
How can I get the prompt back to default after leaving the specific directory?
thank you