0

My bash prompt currently starts with the following variables :

\#/\!

which means

\#   The command number of this command.

\!   The history number of this command.

So \# is specific to each terminal but the \! is relative the global history file.

In zsh, %! appears to be equivalent to bash \#.

How do you translate bash \! in zsh ?

2

I don't think you have the equivalent in zsh, but you can do the same thing by using a counter in preexec:

preexec() { psvar[1]=$((cctr++)) }
PS1='%1v/%! '

is more or less equivalent to PS1='\#/\! ' in bash.

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.