From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6881 invoked from network); 3 Aug 2000 09:20:06 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 3 Aug 2000 09:20:06 -0000 Received: (qmail 12982 invoked by alias); 3 Aug 2000 09:19:38 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3354 Received: (qmail 12975 invoked from network); 3 Aug 2000 09:19:37 -0000 Date: Thu, 03 Aug 2000 10:19:05 +0100 From: Peter Stephenson Subject: Re: How to avoid expansion when completing? In-reply-to: "Your message of Thu, 03 Aug 2000 08:51:26 BST." <20000803085126.I13662@bri.st.com> To: zsh-users@sunsite.auc.dk (Zsh users list), Richard Curnow Message-id: <0FYP004HWLVT39@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > Suppose I have a load of subdirectories, each of which contains a file > called foobar.dat. I enter > > % wc **/foob > > hoping to expand this to **/foobar.dat (assuming there's nothing else > starting with 'foob' in any of the subdirectories). However, I get the > '**' expanded to the first subdirectory name which has a file starting > with 'foob' in it. (If I keep pressing then I cycle round). > > I've got the following options set, and I'm running version 3.1.5. If you don't mind upgrading, you can do such things with the new bindable completion widgets in 3.1.9 (maybe 3.1.6, but that's irrelevant if you're still on 3.1.5). Assuming the file is unique, you can use e.g. _most_recent_file (usually bound to ^xm), which would normally put a `*' on the end and find the most recently modified matching file --- that ought to be enough for this purpose. The following function is a trivial modification of that to add all matching files as possible completions (_glob_expand_and_complete). Sven probably has a better way of doing it. #compdef -k complete-word \C-xG local file tilde etilde if [[ $PREFIX = \~*/* ]]; then tilde=${PREFIX%%/*} etilde=${~tilde} file=($~PREFIX*$~SUFFIX) file=(${file/#$etilde/$tilde}) else file=($~PREFIX*$~SUFFIX) fi (( $#file )) && compadd -U -i "$IPREFIX" -I "$ISUFFIX" -f -Q $file -- Peter Stephenson Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070