What does the sequence %\/ do in zsh prompt expansion? man zshmisc doesn't contain the string %\, which is where the rest of the prompt-specific expansions are.

The sequence can be seen in Holmans dotfiles:

  echo "%{$fg_bold[cyan]%}%1/%\/%{$reset_color%}"

export PROMPT=$'in $(directory_name)› '

%\ does nothing so is useless. Same for the $ in $'...'. No need for it since there's no escape sequence to expand there.

The whole thing can be written:

PS1='in %{$fg_bold[cyan]%}%1//%{$reset_color%}› '


PS1="in %{$fg_bold[cyan]%}%1//%{$reset_color%}› "

to have the $fg_bold... expanded at the time of that assignment rather than at each prompt.

No need to do the command substitution at each prompt since the output of directory_name doesn't change from one run to the next.

You probably don't want to export PS1 or PROMPT either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.