Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to do completion with read?
- X-seq: zsh-users 2719
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Paul Lew <paullew@xxxxxxxxx>, zsh-users@xxxxxxxxxxxxxxx
- Subject: Re: How to do completion with read?
- Date: Wed, 3 Nov 1999 17:18:29 +0000
- In-reply-to: <14368.26696.664675.141950@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <14368.26696.664675.141950@xxxxxxxxxxxxxxxxxxxxxxx>
On Nov 3, 8:52am, Paul Lew wrote:
} Subject: How to do completion with read?
}
} Is there a way to use completion mechanism when prompt user for input
} in zsh function/scripts?
Here's my "zleread" function again. Insert some commands to fiddle with
the completion context just before the call to "vared" and you can get it
to complete any way you like.
--- 8< --- cut here --- 8< ---
emulate -L zsh
local input opt ropt n=0
ropt=()
while getopts :AEe opt
do
case $opt in
[?]) read $*; return $?;;
+*) break;;
*) ropt=($ropt -$opt); ((++n));
esac
done
if [[ -t 0 ]]
then
shift $n
vared -hp "${${(M)1%%\?*}#\?}" input
print -r $input | read $ropt ${1%%\?*} $*[2,-1]
return $?
fi
read $*
--- 8< --- cut here --- 8< ---
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author