0

I recently changed my Zsh prompt to match a theme I like from oh-my-zsh (I'm ditching oh-my-zsh for compatibility reasons).

The prompt is:

PROMPT='%(?,%{$fg[green]%},%{$fg[red]%}) %% '
RPS1='%{$fg[blue]%}%~%{$reset_color%} '

I had multiple tmux panes open when I made this change to my ~/.zshrc file. When I exited vim and entered source ~/.zshrc zsh rendered the prompt correctly. When I tried switching panes, and entering source ~/.zshrc it rendered incorrectly, and it has rendered incorrectly on all subsequent panes and windows created.

In the photo, the first pane I sourced ~/.zshrc in is on the left.

First pane | Second pane

  • What do you mean by “first tmux pane I sourced ~/.zshrc in”? Do you run zsh in both panes? If so .zshrc would have been sourced when you start zsh. Please post a way to reproduce this (including how to start tmux and create the panes), including all relevant tmux and zsh configuration files. – Gilles Jun 30 '17 at 21:37
  • What it looks like is that the zsh configuration is different in the two panes, the one on the left has the prompt_subst option set and the one on the right doesn't. – Gilles Jun 30 '17 at 21:38
  • Edited for more detail, adding export PROMPT_SUBST did the trick. Would you like to submit an answer so I can mark this as answered? – Jones Jun 30 '17 at 21:49
1

You evidently have different zsh configurations in the two panes. Make sure that the prompt_subst option is set. It seems that you set it in the left pane but it isn't present in your configuration. Add the following line to your .zshrc:

shopt -s prompt_subst

Note that if you use a framework such as oh-my-zsh, changing the value of this option may mess up its prompt setting framework. I don't use zsh configuration frameworks so you're on your own with that.

  • Of course, if one is going to use % sequences anyway one might as well use %F{red} and its ilk, get rid of $fg and $reset_color, and not have to worry about prompt_subst in the first place. – JdeBP Jul 3 '17 at 17:21

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.