2af2d1aa31caa534c419e72d75daa667ff725de2

Author
kg <kjxstar@gmail.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

add autocomplete for adb -s option (#6121)

Diff

 1diff --git a/plugins/adb/README.md b/plugins/adb/README.md
 2index 075beec0e3733e06035f7e982a9aef58b5438f1b..83dcc728808eb0b7a38190b6c18aecdbb69e178f 100644
 3--- a/plugins/adb/README.md
 4+++ b/plugins/adb/README.md
 5@@ -1,7 +1,7 @@
 6 # adb autocomplete plugin
 7 
 8 * Adds autocomplete options for all adb commands.
 9-
10+* Add autocomplete for `adb -s`
11 
12 ## Requirements
13 
14diff --git a/plugins/adb/_adb b/plugins/adb/_adb
15index 5f37bedac1e5ddfee9fbfff4848e672354cda3b7..2e3c3658e1a6192b4d6a1474c6c8772225efc460 100644
16--- a/plugins/adb/_adb
17+++ b/plugins/adb/_adb
18@@ -43,11 +43,20 @@ local expl
19 local -a pkgs installed_pkgs
20 
21 _arguments \
22+	'-s[devices]:specify device:->specify_device' \
23 	'*:: :->subcmds' && return 0
24 
25+case "$state" in
26+	specify_device)
27+	_values  'devices' $(adb devices|awk 'NR>1&& $1 ~ /^[a-zA-Z0-9].*$/ \
28+		{printf "%s[Device_%d:%s] ",$1,++i,$2 }')
29+	return
30+	;;
31+esac
32+
33 if (( CURRENT == 1 )); then
34 	_describe -t commands "adb subcommand" _1st_arguments
35 	return
36 fi
37 
38-_files
39+_files