zshzsh-zle

RPROMPT not showing on initial prompt


I'm seeing a strange issue when trying to use RPROMPT to configure my zsh prompt. I'm not using oh-my-zsh or any other plugin manager. Here is my .zshrc file:

function zle-line-init {
  RPROMPT="foo"
  zle reset-prompt
}

zle -N zle-line-init

However, on the first prompt (when opening a new shell, or new tmux window/pane), the foo doesn't show. (I then press enter and the RPROMPT shows for the new prompt.)

Why doesn't it show on the first one?


Solution

  • When zsh first prints the initial prompt, RPROMPT is not set so the feature is disabled. Just set RPROMPT to anything outside the zle-line-init function.