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.
zle -R $'\e[31mls\e[00m - list files'
doesn't work? – Cuminzle -R $'ls - \n list files'
– Cumin'\n'
but$'\n'
; because you didn't comment on that construct I wasn't sure that you tested it, sorry for that – Cuminzle -R
can't output any kind of control characters, at least that was the case at the time of this thread (which is pretty old to be fair) – Tulley