about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2017-01-13 03:52:25 +0100
committerOliver Kiddle <opk@zsh.org>2017-01-13 03:52:25 +0100
commitf22960c8e1e0d5d1f34023aa64e1f602ae345945 (patch)
treec13e8ae31a796f8b5f634a3686d6b93cff71b2f4 /Completion
parentcfc8165bc14df6632b8f44aa8707fecd74d47098 (diff)
downloadzsh-f22960c8e1e0d5d1f34023aa64e1f602ae345945.tar.gz
zsh-f22960c8e1e0d5d1f34023aa64e1f602ae345945.tar.xz
zsh-f22960c8e1e0d5d1f34023aa64e1f602ae345945.zip
40345: update lsusb completion
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Linux/Command/_lsusb30
1 files changed, 17 insertions, 13 deletions
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