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

Re: Cannot use LBUFFER+= nor print -zr from zsh/sched call

On Sep 13,  7:29pm, Sebastian Gniazdowski wrote:
} Nice trick with print -S, thanks. I had in mind the
} execute-without-simulating-input and plan to include it as option. Am
} quite afraid to run things without people's eyes.

I find this statement puzzling, because if you do an accept-line from
inside the convey-handler, you're still potentially executing before
anyone sees the commands.  Making them visible during/after they've
executed isn't especially helpful if they're doing something they

However, you can certainly accomplish displaying what's being done
without having to poke it into the editor buffer.  Minimally, you
can do (again using "sched -o")

    for histent in "$commands[@]"; do
      # sched -o will clean up zle for us, so fake a prompt ...
      print -Prn -- "$PS1"
      # ... show the command we're about to run ...
      print -r -- "$histent"
      # ... put it in the history ...
      print -Sr -- "$histent"
      # ... and then run it
      eval "$histent"

This has to vary a little depending on the format of $commands (the
above presumes it's an array of one command per element) but you get
the idea.

Messages sorted by: Reverse Date, Date, Thread, Author