I know that it is possible to display text outside of the zsh prompt where you are typing. Common example is completions:myhost Wed 8 10:06 ~/sandlot $ e .pyPress Tab, et voil:myhost Wed 8 10:06 ~/sandlot $ e .py -- file --lenum.py           lexample.py        otherticks.pyWhat interests me is the text from --file-- below. Is there some kind of zsh_echo_below_zle or something. I don't mind about about keyboard or shortcuts, since my intention is to run and use the output in zle. S.a.myhost Wed 8 10:06 ~/sandlot $ some_command $(some_command_with_warning)Press Tab, andmyhost Wed 8 10:06 ~/sandlot $ some_command some_output -- warning: some_output is about yadda yadda yadada --
Write warning while typing in zsh prompt
zsh;zle
Inside the ZSH completion system, a custom message upon mashing of tab for a particular argument of a command is possible via the _message function, as shown in this completion script (_foo) for a particular command (foo):#compdef foolocal curcontext=$curcontext state_arguments -C -s \  '1: :->dofoo' \  && return 0case $state in  dofoo)    _message -r  -- warning: lp0 on fire    _values parameters $(_call_program getparam echo aaa bbb)  ;;esacE.g.% ls $fpath[*]/_foo 2>/dev/null/Users/jdoe/.zsh/functions/_foo% rm ~/.zcompdump && exec zsh% function foo () { echo $@ }% foo  -- warning: lp0 on fireaaa  bbb          (When modifying $fpath to include a custom directory, always do that before the autoload -U compinit && compinit commands.)However, given a command line of echo $(foo bar), the completion _foo is not involved when tab is mashed, as this is a command substitution, and not an autocompletion of foo.During command substitution, the command being substituted has no indication whether it is being run directly or as a command substitution (there is a special ZSH_EVAL_CONTEXT variable though exporting that only indicates toplevel regardless), and writing to the terminal then restoring the cursor position will be complicated:% cat awkward #!/bin/zshecho -ne \e7\n -- warning: lp0 on fire\e[F\e8 >/dev/tty; echo blat% ./awkward blat% echo $(./awkward)... though that's hardly perfect, as if the prompt is down at the bottom of the screen, horrible buggy things happen:% echo -ne \e[$LINES;0H...% ./awkward blatwarning: lp0 on fire% echo $(./awkward ) -- warblat         fireA more complicated program would need to deal properly with being at the bottom of the terminal, or even use ncurses for portability, and will need to somehow indicate to zsh that any custom line(s) written (may) need to be cleared so the display does not risk being mucked up with the output of a subsequent command. But that's more work.The zsh code in Src/exec.c does not look like it does anything special for a cmdsubst job, and the preexec hook function is not called for command substitution, either. So I'm really not seeing anything simple for custom below-the-prompt terminal messaging during the execution of a command substitution in zsh.