]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/adb/_adb
initial
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / adb / _adb
1 #compdef adb
2 #autoload
3
4 # in order to make this work, you will need to have the android adb tools
5
6 # adb zsh completion, based on homebrew completion
7
8 local -a _1st_arguments
9 _1st_arguments=(
10 'bugreport:return all information from the device that should be included in a bug report.'
11 'connect:connect to a device via TCP/IP Port 5555 is default.'
12 'devices:list all connected devices'
13 'disconnect:disconnect from a TCP/IP device. Port 5555 is default.'
14 'emu:run emulator console command'
15 'forward:forward socket connections'
16 'get-devpath:print the device path'
17 'get-serialno:print the serial number of the device'
18 'get-state:print the current state of the device: offline | bootloader | device'
19 'help:show the help message'
20 'install:push this package file to the device and install it'
21 'jdwp:list PIDs of processes hosting a JDWP transport'
22 'keygen:generate adb public/private key'
23 'kill-server:kill the server if it is running'
24 'logcat:view device log'
25 'pull:copy file/dir from device'
26 'push:copy file/dir to device'
27 'reboot:reboots the device, optionally into the bootloader or recovery program'
28 'reboot-bootloader:reboots the device into the bootloader'
29 'remount:remounts the partitions on the device read-write'
30 'root:restarts the adbd daemon with root permissions'
31 'sideload:push a ZIP to device and install it'
32 'shell:run remote shell interactively'
33 'sync:copy host->device only if changed (-l means list but dont copy)'
34 'start-server:ensure that there is a server running'
35 'tcpip:restart host adb in tcpip mode'
36 'uninstall:remove this app package from the device'
37 'usb:restart the adbd daemon listing on USB'
38 'version:show version num'
39 'wait-for-device:block until device is online'
40 )
41
42 local expl
43 local -a pkgs installed_pkgs
44
45 _arguments \
46         '-s[devices]:specify device:->specify_device' \
47         '*:: :->subcmds' && return 0
48
49 case "$state" in
50         specify_device)
51         _values -C 'devices' ${$(adb devices -l|awk 'NR>1&& $1 \
52                 {sub(/ +/," ",$0); \
53                 gsub(":","\\:",$1); \
54                 for(i=1;i<=NF;i++) {
55                         if($i ~ /model:/) { split($i,m,":") } \
56                         else if($i ~ /product:/) { split($i,p,":") } } \
57                 printf "%s[%s(%s)] ",$1, p[2], m[2]}'):-""}
58         return
59         ;;
60 esac
61
62 if (( CURRENT == 1 )); then
63         _describe -t commands "adb subcommand" _1st_arguments
64         return
65 fi
66
67 _files