diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Completion/Unix/Command/_adb | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 20848d875..2e40bfa20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,9 @@ * 49963: Completion/Unix/Command/_adb: _adb: Fix device serial completion for hostname:port syntax + * 49964: Completion/Unix/Command/_adb: _adb: Complete services + for start/stop + 2022-04-02 dana <dana@dana.is> * unposted (see 48073): Completion/Zsh/Command/_fc: Complete diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb index a429954a8..8d3eec542 100644 --- a/Completion/Unix/Command/_adb +++ b/Completion/Unix/Command/_adb @@ -195,6 +195,9 @@ _adb_dispatch_shell () { (dumpsys) (( $+functions[_adb_dumpsys_handler] )) && _adb_dumpsys_handler ;; + (start|stop) + (( $+functions[_adb_startstop] )) && _adb_startstop ${words[2]} + ;; (*) _arguments '*: :_adb_remote_folder' ;; @@ -339,6 +342,17 @@ _adb_dumpsys_handler () { _wanted dumpsys expl 'dumpsys service' compadd ${services%$'\r'} } +(( $+functions[_adb_startstop] )) || +_adb_startstop () { + local -a services + local -A service_status + services=(${(f)"$(adb ${ADB_DEVICE_SPECIFICATION} exec-out getprop)"}) + service_status=( ${(s,: ,)${(j,: ,)${(M)services:#\[init.svc.*}}} ) + local -A map=(start stopped stop running) + services=( ${(k)service_status[(R)*$map[$1]*]} ) + _wanted services expl "$map[$1] services" compadd - ${${${services#\[}%\]}#init.svc.} +} + (( $+functions[_adb_dispatch_uninstall] )) || _adb_dispatch_uninstall () { _arguments \ @@ -486,7 +500,7 @@ _adb_options_handler() { (( $+functions[_adb_shell_commands_handler] )) || _adb_shell_commands_handler() { local expl - _wanted adb_shell_commands expl 'adb shell command' compadd ls pm am mkdir rmdir rm cat cmd dumpsys + _wanted adb_shell_commands expl 'adb shell command' compadd ls pm am mkdir rmdir rm cat cmd dumpsys start stop } (( $+functions[_adb_device_available] )) || |