Bash – Highlight path separators in PS1

bashprompt

I want to do something like this in Bash:

how to format the path in a zsh prompt?

But everything I try results in the PWD being fixed to the first directory I start my terminal in. Strangely I've also got a function in my PS1 to put the current git branch in the prompt and that always updates so I'm confused as to why the PWD gets stuck. My current prompt is here incidentally.

I tried replacing \w with $(pwd|grep --color=always /) but that just gets stuck. I also tried doing it using a bash string replacement but that doesn't work either. ${PWD////$bldred/$bldblu} ($bldred and $bldblu are defined in my prompt.sh).

Best Answer

When including a dynamic variable in your prompt you need to quote it.

I don't quite understand some of your PROMPT_COMMAND stuff, but try PS1='${PWD////'"$bldred/$bldblue"'} \$' by itself and see if it works.

Related Question