zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _lsusb
@ 2007-09-30 11:38 Clint Adams
  0 siblings, 0 replies; only message in thread
From: Clint Adams @ 2007-09-30 11:38 UTC (permalink / raw)
  To: zsh-workers

Completion for lsusb

Index: Completion/Linux/Command/_lsusb
===================================================================
RCS file: Completion/Linux/Command/_lsusb
diff -N Completion/Linux/Command/_lsusb
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Linux/Command/_lsusb	30 Sep 2007 11:37:22 -0000
@@ -0,0 +1,31 @@
+#compdef lsusb
+
+local context state line usbidsline vendorid pair
+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
+
+  if [[ ${+_lsusb_vendors} -eq 0 ]]; then
+    typeset -A _lsusb_vendors _lsusb_devices
+  while IFS="" read usbidsline
+  do
+    case "$usbidsline" in
+      ((#b)([0-9a-f]##) ##(*))
+        vendorid="$match[1]"
+        _lsusb_vendors[$vendorid]="$match[2]"
+      ;;
+      (	(#b)([0-9a-f]##) ##(*)))
+        pair="$vendorid:$match[1]"
+        _lsusb_devices[${pair}]="$match[2]"
+      ;;
+    esac
+  done < <(zcat /var/lib/usbutils/usb.ids)
+fi
+
+compadd -k _lsusb_devices


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-30 11:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-30 11:38 PATCH: _lsusb Clint Adams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).