From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7328 invoked by alias); 6 Feb 2014 03:31:44 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18406 Received: (qmail 10956 invoked from network); 6 Feb 2014 03:31:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=N8uYEfOI/V59waycPDqiXgWxvwzI44udRohu4r2xJXg=; b=gOt7qZjtOsnrk5R6GPhbIgbTWGcsdfn4cNeTpbfrwnqxRq6fQ1OUD5OXdz4+xjvpRf DvIkY30l6exSg7KqMyI7Xvqh9w1jsDCsZH4PpkHwgQ4x2eKQxFTiGAHiSWf1R3/399x7 E35H2TNVG2aqAqc6LFIUngD7oq4L27VEe30BEKwMRft/21Ne69Jw0odw4UteNvGcXE4x Aq7zLaTDRlK2qfOXb4hwaDGiUDDKO4LDbHKhAzpF4OzjLekbT0fVNFL2XmQq2Acgt5Se gLOMNCoyvY7LtFZQmugtu+XajWsz/sUMhbd1Z5WNeA1nNryBRfl6Mv+6pOeWiVg9kPAG PVhA== X-Received: by 10.15.56.8 with SMTP id x8mr5263169eew.83.1391651439689; Wed, 05 Feb 2014 17:50:39 -0800 (PST) Date: Thu, 6 Feb 2014 02:50:34 +0100 From: luc To: Zsh Mailinglists Subject: Re: completion function for system_profiler (OS X) Message-ID: <20140206015034.GA4321@mbp.localdomain> Mail-Followup-To: Zsh Mailinglists References: <20140205120058.GA85309@mbp.localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.22 (2013-10-16) --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello Jun, > You can simply use '*:message:action' as a spec for _arguments. This works perfectly. > Output from $(system_profiler -listDataTypes) contains a header line, > which is removed by ( ${$(f)"$(command)"}[2,-1]} ). > You are using _call_program so a user can replace the command by using > zstyle. But the 1st line of the output from the user-specified command > will also be removed. I am now hardcoding the data types into the array as the call for `system_profiler -listDataTypes` is taking a lot of time sometimes. I think this list hardly ever changes (in new versions of OS X?). I will attach my "final" version again. Is it reasonalble (or desired) to commit this upsream? Thank you for your help Lucas --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=_system_profiler #compdef system_profiler typeset -A opt_args local context state state_descr line local -a _data_types # TODO: Should this be static? Calling `system_profiler -listDataTypes` takes # about 0.07-0.08 secs on my machine. Does this list ever change (between # different versions of OS X)? _data_types=( SP{AirPort,Applications,Audio,Bluetooth,Camera,CardReader,Component,ConfigurationProfile,DeveloperTools,Diagnostics,DisabledSoftware,DiscBurning,Displays,Ethernet,Extensions,FibreChannel,FireWire,Firewall,Fonts,Frameworks,Hardware,HardwareRAID,InstallHistory,Logs,ManagedClient,Memory,Network,NetworkLocation,NetworkVolume,PCI,ParallelATA,ParallelSCSI,Power,PrefPane,Printers,PrintersSoftware,SAS,SPI,SerialATA,Software,StartupItem,Storage,SyncServices,Thunderbolt,USB,UniversalAccess,WWAN}DataType ) # the dynamic alternative is: #_data_types=( ${${(f)"$(_call_program path system_profiler -listDataTypes 2>/dev/null)"}[2,-1]} ) _arguments \ '(- *)-usage' \ '(- *)-listDataTypes[lists the available datatypes]' \ '(-listDataTypes -usage)-xml[generate xml output]' \ '(-listDataTypes -usage)-detailLevel[level of detail for the report]:detail level:(mini basic full)' \ '(-listDataTypes -usage)-timeout+[maximum time to wait in seconds]' \ '(-listDataTypes -usage)*:data type:'"($_data_types)" --ZPt4rx8FFjLCG7dd--