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

Re: Duplicating TRANSIENT_RPROMPT for left PROPMT?



On Wed, Oct 23, 2013 at 8:47 AM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>wrote:

> On Oct 22,  4:22pm, Jesse Hathaway wrote:
> }
> } The unusual part of my prompt is the vi mode at the bottom of my screen.
> } Does anyone have thoughts on the best way to clear the prompt before the
> } command is entered?
>
> The best solution to this is to NOT put the vi mode in the prompt, but
> instead use "zle -M" to display it.  Simplest way is like this:
>
> PS1='%~ '
> vim_ins_mode="-- INSERT --"
> vim_cmd_mode=""
>
> function zle-keymap-select {
>
> vim_mode="${${KEYMAP/vicmd/${vim_cmd_mode}}/(main|viins)/${vim_ins_mode}}"
>   zle -M -- "$vim_mode"
> }
> zle -N zle-keymap-select
> zle -N zle-line-init zle-keymap-select
>

Thanks for your suggestions Bart

I tried the zle -M approach, but it seemed to result in my cursor sometimes
being at the bottom of the output, and them sometimes the vim_mode prompt
appearing, i.e. my cursor was jumping up and down.

I ended up adding a preexec which solves the problem:

# Clear vim_mode prompt before executing command, as the command output
will be
# written to same line as the vim_mode prompt on the terminal
function preexec {
  echo -n "$terminfo[el]"
}


> This and your original scheme both seem to suffer from the problem that
> any completion listing covers up the "mode message" and it doesn't return
> until you toggle through command/insert again.


Yeah this is definitively not great, I spent some time trying to determine
how to solve the problem, but I haven't come up with anything yet. I would
love suggestions. I couldn't find any hooks to use when suggestions fire. I
am also considering diving into the zsh source and look into adding proper
support for a BOTTOM_PROMPT.

Thanks, Jesse


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