del-prompt-accept-line() { OLD_PROMPT="$PROMPT" PROMPT="> " zle reset-prompt PROMPT="$OLD_PROMPT" zle accept-line } zle -N del-prompt-accept-line bindkey "^M" del-prompt-accept-line This breaks for multiline command lines like
> echo one\ > two I don't want it to change PROMPT until the command is actually run, not just when pressing enter in the command line.
del-prompt-accept-line() { OLD_PROMPT="$PROMPT" PROMPT="> " zle reset-prompt PROMPT="$OLD_PROMPT" zle accept-line } autoload -Uz add-zsh-hook add-zsh-hook preexec del-prompt-accept-line now this version (trying to use preexec, the only applicable hook I know about) causes the error
widgets can only be called when ZLE is active
So how can I make a prompt that looks like
directory % while I am editing the command line, then changes to
> when I run the command line?
When I scrollback, I want to only see > prompts
accept-linethe first line, then it edits a new line (and switches to the PS2 prompt). At that point, as far as ZLE is concerned the previous line is history, you can't get back to that and edit the prompt that was displayed for a previously edited line.accept-lineif the current buffer contains complete code (would not cause a PS2 prompt for additional lines) and inserts a newline character into the editing buffer otherwise likefishdoes. IIRC, that approach has already been answered here.