Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
how to update RPROMPT each time a key is pressed
- X-seq: zsh-users 30268
- From: Trevor Avant <trevoravant@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: how to update RPROMPT each time a key is pressed
- Date: Sat, 7 Jun 2025 22:08:36 -0400
- Archived-at: <https://zsh.org/users/30268>
- List-id: <zsh-users.zsh.org>
I am trying to create a function that updates RPROMPT when I have typed "cd .." into the terminal. Here is the code that I added to my .zshrc as an attempt to make this work:
function self-insert() {
zle .self-insert
if [[ $BUFFER == "cd .." ]]; then
RPROMPT="ABC"
zle reset-prompt
fi
}
zle -N self-insert
The effect of this command is that my RPROMPT gets set to ABC, but only after I have executed the command, rather than once I have typed the command. However, if I were to update RBUFFER in that if-statement, then it would get updated once I have typed the command. So I would like to make RPROMPT get updated like RBUFFER would.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author