${(%)…}: Expand as prompt

Expands all % escapes in the same way as in prompts. %% is enabling full prompt expansion.

Examples

Print username, TTY, and machine using prompt expansion
1
2
message='User "%n" on TTY "%l" on machine "%M"'
echo ${(%)message}
Output:
1
User "UserName" on TTY "pts/1" on machine "MachineName"
BashSupport Pro is a Zsh IDE with support for ${(percent)…}try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal