From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8806 invoked by alias); 13 Jan 2017 00:44:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40345 Received: (qmail 28509 invoked from network); 13 Jan 2017 00:44:24 -0000 X-Qmail-Scanner-Diagnostics: from nm12-vm5.bullet.mail.ir2.yahoo.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.82.96.175):SA:0(-1.8/5.0):. Processed in 1.043995 secs); 13 Jan 2017 00:44:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 212.82.96.175 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1484267871; bh=fujEWd0/8utg/DDzaxPGrs88JmQCSswBtl6b0sB3boI=; h=From:To:Subject:Date:From:Subject; b=JijaMBe6YHAAAVdzTqBBsg8fg98wmbfvOFcIEuKAUw9bHM9/kKv0A/WzJfuzH7p7qa1pXJNNUuEMxkTsn8+lMTe9pAO1BgcLnPxpBGnlHMTo5v4BddkyMyl7keH0zNP5s+lGilveFHU8N+DhR07QMsSpy76XGpDBrv+F777b73ZIp6a8yDkm0m0bcQEUPvWPnh/6F8enCGp5BQBKQMSssuQMoJNVWq2qKGuGZneic+UfY7CNPT9C6fcKDTjG8hltYAFtnaYj0Ho6JHV3BIYkucBgx63NUCd+L3FCo3DkEOB8UFSiiV63uyU2JB3LRZHdAa1v4tLx0dDl8blYw4g5BA== X-Yahoo-Newman-Id: 843916.26249.bm@smtp129.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: ivn2IM4VM1mpjmiueCVGI9P4p9MQav22cbguHl4UVnMiLFo gORfmZFyrqfsUcGtrpDt8DFllBAXjt9jHsejmYYQArNYFR1QLEB8pwowBQZS 6.wmQKxFsuiOyFfnyueacb6a1ScnjBlVmKL7SXlFFVzzR7RcSt3jzvQtfd_3 E_oy2voja8NXnA4_2O4__ieW6C94iMamBTYz09XUQdIiakCg6ZcJZPhgeAi1 UZLdHVyrEubj7XA20.ScZwnwu7pDcAiGjxLBB_a8bMc6yl98iLrl6.rC.hHY VuEg6pgw98bZXJDszQUt4LN7P_mvVTDRMV6coYGljeARO4JvVq1OiGVhsalk T0jMLpS6EML3OPlCQR2uSogZ6ZVF6KiANsN7kF_llWW3fCgVmmghic.nqwsK ZifXp7.HsCnD63ZUG_88YiRqzT49atGq77rDIqtHFhj4c1AW5WhqMr55Jbxl Jkk_PjZHePvk18Ru7hyh94hBH.1Nd_rGuHuCKhQN4INSMjnM_vJm3gimS3H_ 8j3VpYX56_cqNKpSjEKrT492D4O0vzZ2CTTyxddcy X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: lsusb completion update MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <55472.1484266590.1@hydra.kiddle.eu> Date: Fri, 13 Jan 2017 01:16:30 +0100 Message-ID: <55473.1484266590@hydra.kiddle.eu> After adding _lsblk, I noticed _lsusb an a quick check showed it was only really missing --tree. I also added some exclusions and descriptions and the usb.ids file is in a different path on my system. I'm not sure completing all IDs is particularly useful but whatever. Oliver diff --git a/Completion/Linux/Command/_lsusb b/Completion/Linux/Command/_lsusb index 17240e03d..1807f5e93 100644 --- a/Completion/Linux/Command/_lsusb +++ b/Completion/Linux/Command/_lsusb @@ -1,19 +1,21 @@ #compdef lsusb -local context state line usbidsline vendorid pair +local usbidsline vendorid pair ret=1 +local curcontext="$curcontext" state line expl typeset -A opt_args -_arguments \ - '(-v --verbose)'{-v,--verbose}'[be verbose]' \ - '-s:bus and/or devnum to show:' \ - '-d:vendor and product to show:->vendorproduct' \ - '-D:device to show:_files' \ - '-t[dump the physical USB device hierarchy as a tree]' \ - '(-V --version)'{-V,--version}'[print version info and exit]' && return 0 +_arguments -C \ + '(-v --verbose -t --tree)'{-v,--verbose}'[be verbose]' \ + '-s+[filter devices by bus and/or device number]:bus and/or devnum to show' \ + '-d+[filter devices by vendor/product ID]:vendor and product to show:->vendorproduct' \ + '-D+[display only specified device]:device:_files -g "*(-%)" -P / -W /' \ + '(-t --tree -v --verbose)'{-t,--tree}'[dump the physical USB device hierarchy as a tree]' \ + '(-)'{-V,--version}'[print version information]' \ + '(-)'{-h,--help}'[print help information]' && ret=0 - if [[ ${+_lsusb_vendors} -eq 0 ]]; then - typeset -A _lsusb_vendors _lsusb_devices - while IFS="" read usbidsline +if [[ -n $state && ${+_lsusb_vendors} -eq 0 ]]; then + typeset -A _lsusb_vendors _lsusb_devices + cat /usr/share/(misc|hwdata)/usb.ids | while IFS="" read usbidsline do case "$usbidsline" in ((#b)([0-9a-f]##) ##(*)) @@ -25,7 +27,9 @@ _arguments \ _lsusb_devices[${pair}]="$match[2]" ;; esac - done < /usr/share/misc/usb.ids + done fi -compadd -k _lsusb_devices +_wanted vendors:products expl 'vendor ID:product ID' compadd -k _lsusb_devices && ret=0 + +return ret