man zshall and search for PROMPT EXPANSION
After reading the existing answers here, some of them conflict. I tried various approaches to systems working with zsh 4.2 and 5+, and found that the reason these answers contradict each other is because they do not say which version of ZSH they are aimed at. Different versions use different syntax for this, and some of them require different startups.
So, the best option is probably for a zshall person and search for PROMPT EXPANSION to find out all the rules for your particular zsh installation. Check out the comments, things like "I'm using Ubuntu 11.04 or 10.4 or OSX." Not very significant because it is not clear which version of ZSH you are using. Ubuntu 11.04 does not imply a newer version of ZSH than Ubuntu 10.04. There may be several reasons why an older version was installed. In this case, the newer version of ZSH does not imply which syntax to use without knowing which version of ZSH it is.
cs_alumnus Jul 17 '14 at 16:02 2014-07-17 16:02
source share