I would like to execute a zle command without binding it to a key. The only solution I currently see is something like this.
cmd() { RBUFFER="some text to enter into the prompt" }
zle -N cmd
bindkey '^]'
sleep 0.05 && xdotool key Control+bracketright
If I would source this piece it would directly execute the widget, but this is rather ugly. Is there a way to execute the widget directly from inside the shell, or even from a script, without sourcing it?
EDIT:
what I maybe generally would like to have is a way to manipulate zle stuff like RBUFFER, LBUFFER etc. from any zsh script.
TRAPALRM, which is cool, but the minimum possible time (as it looks) is 1 second, so the function will be called each second, and for my purpose that wouldn't be snappy enough tbh. – Dimfred Apr 19 '22 at 21:51RBUFFERetc. is only meaningful when there is something written on the command line ("zle is active"), but how do you want to execute a script then? If you want to prefill the commandline, maybeprint -zwill help you. – mpy Apr 20 '22 at 17:34zsh -c print -z "bla"it won't work. The thing is I just want to have 100% control overzlestuff, from external.Currently I achieved this by reading a queue during trapalarm, and execute the read command. A command e.g. could be
– Dimfred Apr 21 '22 at 10:10RBUFFER=bla; zle reset-prompt. So externally I now can push something into the buffer and it is interpreted inzlecontext. ButTMOUTcan only be set to 1 second, and thats not snappy enough for me as said.add-zle-hook-widgetfunctionality of zsh > 5.8. – mpy Apr 21 '22 at 18:14