I want to create a widget bound to a hotkey that prints the current command description in rich text below the prompt, then erases it after a keypress. Like so (simplified):
widget() {
zle -R "ls - list files"
read -k 1
}
zle -N widget
bindkey '\eg' widget
But zle -R
can print only plain text, it doesn't even support line breaks. I want to print text with color and line breaks like ^[[31mls^[[00m - list files
.
What approaches can I use to do that?
Just printing it to a regular stdout then initializing a new prompt would be a bad user interface for my use case. That would be an undesirable solutions.
I want it to appear below the prompt and work similarly to zsh-autocomplete, ctrl+R, or fzf. The output doesn't have any complex interactions, it only appears on hotkey and disappears on keypress after that.
The zsh-autocomplete repo does similar, but I don’t know how it is done.