Autocomplete disconnect command
I found this useful when I have many ADB devices (especially cuttlefish
or VMs).
Test: manual
Change-Id: Ie7bfec0b55c76cfa0c850b95a8028e548a7393d3
diff --git a/adb.bash b/adb.bash
index 8fc343f..ad62eba 100644
--- a/adb.bash
+++ b/adb.bash
@@ -77,8 +77,7 @@
COMPREPLY=( $(compgen -W "$OPTIONS $COMMAND" -- "$cur") )
;;
OPT_SERIAL_ARG)
- local devices=$(command adb devices 2> /dev/null | grep -v "List of devices" | awk '{ print $1 }')
- COMPREPLY=( $(compgen -W "${devices}" -- ${cur}) )
+ _adb_devices
;;
COMMAND)
if [[ $i -eq $COMP_CWORD ]]; then
@@ -86,6 +85,9 @@
else
i=$((i+1))
case "${cur}" in
+ disconnect)
+ _adb_devices
+ ;;
install)
_adb_cmd_install "$serial" $i
;;
@@ -118,6 +120,12 @@
return 0
}
+_adb_devices() {
+ local devices=$(command adb devices 2> /dev/null | grep -v "List of devices" | awk '{ print $1 }')
+ COMPREPLY=( $(compgen -W "${devices}" -- ${cur}) )
+ return
+}
+
_adb_cmd_install() {
local serial i cur where