From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19519 invoked from network); 18 May 2006 01:19:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 May 2006 01:19:11 -0000 Received: (qmail 20795 invoked from network); 18 May 2006 01:19:05 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 May 2006 01:19:05 -0000 Received: (qmail 14556 invoked by alias); 18 May 2006 01:18:52 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10272 Received: (qmail 14546 invoked from network); 18 May 2006 01:18:52 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 18 May 2006 01:18:52 -0000 Received: (qmail 19277 invoked from network); 18 May 2006 01:18:52 -0000 Received: from 24-241-49-70.static.athn.ga.charter.com (HELO gkar.zhar.net) (24.241.49.70) by a.mx.sunsite.dk with SMTP; 18 May 2006 01:18:50 -0000 Received: from [192.168.1.7] (helo=mollari.zhar.net) by gkar.zhar.net with smtp (Exim 3.36 #1 (Debian)) id 1FgXEm-0002e7-00 for ; Wed, 17 May 2006 21:23:36 -0400 Received: by mollari.zhar.net (sSMTP sendmail emulation); Wed, 17 May 2006 21:18:48 -0400 Date: Wed, 17 May 2006 21:18:48 -0400 From: John Eikenberry To: zsh users Subject: Completion for unknown command Message-ID: <20060518011847.GA5095@mollari.zhar.net> Mail-Followup-To: John Eikenberry , zsh users MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.11 I have a command I'd like to make completions work with. Unlike the other unknown commands in the wiki this command doesn't complete with files, users, hosts or arguments. It completes with values read/parsed from a file. The command is 'cda' and is a zsh function wrapper around cdargs [1]. It is autoloaded. I originally thought I would be able to do the completion with a zstyle command similar to adding ssh hosts. It used the default (all-files) which I didn't want to extend, so I thought to change that. So I looked into using compdef to change it from the default, but I couldn't find an appropriate builtin function to use. I ended up writing my own completion function to use with compdef [2]. This works, I just thought there would be a easier way to add the completion via zstyles. Looking at what I have below, does anyone know of a simpler way? Thanks for any tips. [1] function cda () { cdargs -f $CDA_BOOKMARKS -o $CDA_RESULT "$1" && cd "`cat "$CDA_RESULT"`" ; } [2] # $CDA_BOOKMARKS is an env var with the location of the bookmarks file used # by cdargs. _cda() { local expl local -a cda_bookmarks cda_bookmarks=(${${(f)"$(<$CDA_BOOKMARKS)"}%%\ *}) _wanted cda_bookmarks expl cda compadd -a cda_bookmarks } compdef _cda cda -- John Eikenberry [jae@zhar.net - http://zhar.net] ______________________________________________________________ "It is difficult to produce a television documentary that is both incisive and probing when every twelve minutes one is interrupted by twelve dancing rabbits singing about toilet paper." - Rod Serling