I am trying to color my prompt based on the return code of the previous command. I have the following:
PROMPT='%{$fg_bold[cyan]%}%~$(git_prompt_info) %($?.%{fg_bold[cyan]%}.%{$fg_bold[red]%})»%{$reset_color%} '
Specifically I'm having trouble with the %($?.%{fg_bold[cyan]%}.%{$fg_bold[red]%})
portion.
Unfortunately my prompt ends up looking like this:
What am I doing wrong?
EDIT:
After fixing my typo I now have:
PROMPT='%{$fg_bold[cyan]%}%~$(git_prompt_info) %($?.%{$fg_bold[cyan]%}.%{$fg_bold[red]%})»%{$reset_color%} '
My prompt now looks like this:
You forgot the $
for the parameter expansion, and you don't precede the ?
with a dollar; it's a flag for the conditional, not a parameter reference.
%(?.%{$fg_bold[cyan]%}.%{$fg_bold[red]%})
^ ^