mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-21 00:01:26 +01:00
23863: completion for lsusb.
This commit is contained in:
parent
75bf795d60
commit
855d0d2d66
2 changed files with 34 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
|||
2007-09-30 Clint Adams <clint@zsh.org>
|
||||
|
||||
* 23863: Completion/Linux/Command/_lsusb: completion
|
||||
for lsusb.
|
||||
|
||||
* 23863: Completion/Unix/Command/_git: remove all
|
||||
global variables.
|
||||
|
||||
|
|
31
Completion/Linux/Command/_lsusb
Normal file
31
Completion/Linux/Command/_lsusb
Normal file
|
@ -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
|
Loading…
Reference in a new issue