Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
edit-command-line widget
- X-seq: zsh-workers 13323
- From: Clint Adams <schizo@xxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: edit-command-line widget
- Date: Thu, 4 Jan 2001 12:06:04 -0500
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
My coworker, who is constantly nagging me about the failings of
zsh's vi-mode, discovered that if he engages the edit-command-line
widget in the midst of a while loop, he will be thrust into $VISUAL
with a single line similar to
'while> echo blah blah blah'
Apparently bash will provide vi the entire loop, changing
newlines to semicolons. ksh seems to beep stupidly and do nothing.
The useful thing would be to keep the same formatting, which is what
the following widget does. I'm tempted to replace edit-command-line
with it, but maybe it should remain a separate widget. Any thoughts?
---8<--snip--8<---
local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
print -R - "$PREBUFFER$BUFFER" >$tmpfile
exec </dev/tty
${VISUAL:-${EDITOR:-vi}} $tmpfile
zle kill-buffer
BUFFER=${"$(<$tmpfile)"/$PREBUFFER/}
CURSOR=$#BUFFER
command rm -f $tmpfile
zle redisplay
Messages sorted by:
Reverse Date,
Date,
Thread,
Author