I have a zsh prompt script that uses print -P to perform prompt expansion. The script does not work properly on a particular remote system that I ssh into. The color directives in the prompt print commands are not being expanded:

$ print -P '%F{blue}this should be blue'
{blue} this should be blue

Is there a way around this? I'm not sure why it should matter that I am using a remote system, since the display is happening through my local terminal emulator (iTerm2).

  • Which version of zsh (echo $ZSH_VERSION) are you using on this particular system? And does `print -P '%4Fthis should be blue' work better?
    – Adaephon
    Commented Sep 25, 2014 at 5:54
  • @Adaephon Thanks, your comment led me to the answer. Commented Sep 25, 2014 at 14:44

1 Answer 1


The problem was that the version of zsh was 4.3.6. According to the release notes, the %F color expansion feature of the prompt was not added until 5.0 (though the release notes aren't 100% clear here-- in any case, %F doesn't show up in the 4.3.6 zshmisc manpage, which contains the prompt expansion documentation). Confusingly, the %F is still removed from the format string (apparently without doing anything)-- it's just the argument (the color name or number in braces) that is untouched. I was able to solve the problem by replacing %F{color} strings in my prompt format string with ANSI escape codes (e.g. %F{blue} becomes \e[34m and %f, which resets the color, becomes \e[0m).

  • FYI %F is present as early as 4.3.10, in line with the observation in the release notes that many differences between 4.2 and 5.0 were present in 4.3.17. My guess is that %F was introduced by 4.3.6, just not yet fully implemented.
    – chepner
    Commented Sep 26, 2014 at 1:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .