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

Re: zsh tips for "UNIX Power Tools"



On Mar 4,  1:22pm, Vincent Lefevre wrote:
} Subject: Re: zsh tips for "UNIX Power Tools"
}
} We can have a prompt on the left (the normal prompt), a part of
} the prompt on the right, but can we have one below, that won't
} be corrupted by the completions?

What does "corrupted by completions" mean?  Covered up by a listing?

Having a prompt below the normal prompt is very tricky, because the
output of any command that you run will begin on the same line where
the "below" part of the prompt is.  And of course if you edit a long
line or a multiline buffer, the line editor needs to use that line, so
there's really no way for zsh to "reserve" it.

Here's a trick (usable only in 3.1.6-dev-19 or thereabouts, and later)
that you may find interesting:

self-insert() {
    zle .self-insert
    [[ -o always_last_prompt ]] && zle -R '' "Line: $((${#LBUFFER//[^
]}+1)) / Column: ${#LBUFFER##*
}" || return 0
}
zle -N self-insert

(Yes, those embedded newlines really should be there.)

This uses the completion listing to keep a running display of the line
and column at which you most recently inserted a character.  ZLE knows
how big a buffer it's editing, so it always places this output below
the entire editable text.

Of course this erases any existing completion listing every time you
insert a character (though not every time you complete), but maybe you
can live with that.

Overriding the many other ZLE widgets to make motions, deletions, etc.
also update the line and column is left as an excercise for the reader.
Beware of other packages like `predict-on' (included with 3.1.6-dev-19)
that also may attempt to redefine bindings in incompatible ways.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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