Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

how to update RPROMPT each time a key is pressed



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