Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: lsusb completion update
- X-seq: zsh-workers 40345
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: lsusb completion update
- Date: Fri, 13 Jan 2017 01:16:30 +0100
- 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==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author