_adb 2.2 KB

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