I would like to have a two-line prompt in zsh, but collapse it to a very small one just after pressing ENTER, so that it doesn't show up in the terminal scroll history. After typing two commands, the terminal should look like this while typing the third:
> echo Command 1
Command 1
> echo Command 2
Command 2
+------------ Long prompt ----------+
`> echo typing a new command here…
I tried getting something with the preexec hook and zle reset prompt, but I get the error widgets can only be called when ZLE is active:
$ autoload -U add-zsh-hook
$ hook_function() { OLD_PROMPT="$PROMPT"; export PROMPT="> "; zle reset-prompt; export PROMPT="$OLD_PROMPT"; }
$ PROMPT=$'+------------ Long prompt ----------+\n\`> '
+------------ Long prompt ----------+
`> add-zsh-hook preexec hook_function
+------------ Long prompt ----------+
`> echo Test
hook_function:zle: widgets can only be called when ZLE is active
Test
+------------ Long prompt ----------+
`>