Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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:

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

export PROMPT=$'in $(directory_name)› '
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

%\ 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%}› '

or:

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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