Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: select item from list in modify-current-argument?
- X-seq: zsh-workers 29457
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Marc Weber <marco-oweber@xxxxxx>, zsh-workers <zsh-workers@xxxxxxx>
- Subject: Re: select item from list in modify-current-argument?
- Date: Sat, 04 Jun 2011 11:32:41 -0700
- In-reply-to: <1307144249-sup-4787@nixos>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1307144249-sup-4787@nixos>
On Jun 4, 1:41am, Marc Weber wrote:
}
} select-one first uses echo to show the alternatives, then read to get
} the item index from the user.
}
} However because echo shows many lines the code copied from
} modify-current-argument get's confused.
I'd probably just do this:
_my_quickpath() {
[[ -z "${words[CURRENT]}" ]] && (( CURRENT > 0 && --CURRENT ))
compadd -Q -U $($HQUICKFILE --echo "${words[CURRENT]}")
}
compdef -k _my_quickpath menu-select ^g
I'm not entirely sure about the --CURRENT part but you get the idea.
If you insist on doing it yourself without using a completion widget,
then you need to replace line 24-25 of select-one with something along
the lines of
local -a replies
for i ({1..$#@}) { replies+=( "$i: ${${@[$i]}#$strip}" ) }
read-from-minibuffer "$(print -c "${replies[@]}")"$'\n'
And then replace other calls to "read $opt" with a similar call to
read-from-minibuffer. (Oh, it needs to be autoloaded first.)
This of course renders select-one unusuable outside of ZLE, so you'll
have to make a new function out out it if you want select-one for any
other purpose.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author