From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6027 invoked by alias); 19 Mar 2016 12:36:53 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38186 Received: (qmail 6773 invoked from network); 19 Mar 2016 12:36:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=R9UW7sqEFEzALY99SDoGpUgqStdeJtTjPgmsISiibDw=; b=Mp6MotO01N6Vj10AifpHedKf/1jZvV1t/VxAfRsCKndbQBLLF+dJ6k2W+MGTfaz39r f0nV62ceF6vwUokXhahs3pw4iCwNklS1X+lAsRX1JGK+EVdaFMizAat5sDmV/MZ5PepD //AL51JjhxZ9OycXa4NUiVkV/vksaaBOaD3UKxAgQAbLgO5OU3Qtyj4DCndcFSKdUctY AfXjn6NQ8FxztsgF7OPQL2u1w4kGj08QmF1AyqHQiSaC9DGZ0QvTInBiOTiKMS8iejSm Ob+S8c7nq4ebbIObTGCahC6h1j9qFJe7TG4IL+YJ4QNmoSeWsBe7QZU6dEMKZxfUMyU4 H8WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=R9UW7sqEFEzALY99SDoGpUgqStdeJtTjPgmsISiibDw=; b=GoZlfUCr5Ki8pJdY2WF9MhNXEpC92CMTayVG/GN7AnLtalkbf9C99231doOitsWl8T jtQmyy0ap2viVo9t/XjaLyhRvf9PfFZDPijA7R2igDsucyhT5wLPJl+04tFerybXuXg1 5+B0BjDEiXqHNZPbOe0mNvCN1ZtIGW+GP8A0+igdWzH/ZDw1YMzbFIk2U1Z0zYbCi0KJ TKrqQB0nbML3bsL0HxGgpmU1NSxv+KL0jvfWpN4CR16CUmy9Lo5y+3KtMNenZ1sRlFjF Yz0JkjSiR1EcvAKu3TVG6/8ZpmYcIFG1AW/V+lLf/RH4KiqWW3bjnbimZYZQ6/M0yeFn eJMw== X-Gm-Message-State: AD7BkJJ1LpHUkjY2A1krND91qNIk1p3/aGjmLGdApGoio2kCnxpO5IZ/YHrGxhIwFy7MTw== X-Received: by 10.194.201.130 with SMTP id ka2mr20037420wjc.34.1458391005493; Sat, 19 Mar 2016 05:36:45 -0700 (PDT) From: Mikael Magnusson To: zsh-workers@zsh.org Subject: PATCH: _adb: fix remote file completion + various fixes Date: Sat, 19 Mar 2016 13:36:39 +0100 Message-Id: <1458390999-24565-1-git-send-email-mikachu@gmail.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <32501.1458366974@thecus.kiddle.eu> References: <32501.1458366974@thecus.kiddle.eu> Okay, this restores the dashes from 35531. I also went through and removed all the superfluous (or most of anyway) double quotes in descriptions. I also noticed while testing that remote folder completion 1) used the same cache name as remote packages, so whichever you used first would be the only one working for a while and 2) it was extremely slow. This patch fixes both of those things also. --- Completion/Unix/Command/_adb | 75 ++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 45 deletions(-) diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb index fa05226..c0a2bb2 100644 --- a/Completion/Unix/Command/_adb +++ b/Completion/Unix/Command/_adb @@ -87,7 +87,7 @@ _adb() { '(-d -e )-s[serial]: :_adb_device_serial' \ '( -e -s)-d[device]' \ '(-d -s)-e[emulator]' \ - '1:"options":_adb_options_handler' \ + '1:options:_adb_options_handler' \ '*: : _default' return; @@ -111,37 +111,36 @@ _adb_dispatch_command () { fi case ${curcontext} in - (*:adb:shell) + (*:adb-shell:) (( $+functions[_adb_dispatch_shell] )) && _adb_dispatch_shell ;; - (*:adb:connect|*:adb:disconnect) + (*:adb-connect:|*:adb-disconnect:) (( $+functions[_adb_dispatch_connection_handling] )) && _adb_dispatch_connection_handling ;; - (*:adb:logcat) + (*:adb-logcat:) (( $+functions[_adb_dispatch_logcat] )) && _adb_dispatch_logcat ;; - (*:adb:push) + (*:adb-push:) (( $+functions[_adb_dispatch_push] )) && _adb_dispatch_push ;; - (*:adb:pull) + (*:adb-pull:) (( $+functions[_adb_dispatch_pull] )) && _adb_dispatch_pull ;; - (*:adb:install) + (*:adb-install:) (( $+functions[_adb_dispatch_install] )) && _adb_dispatch_install ;; - (*:adb:uninstall) + (*:adb-uninstall:) (( $+functions[_adb_dispatch_uninstall] )) && _adb_dispatch_uninstall ;; - (*:adb:(${(~j:|:)ALL_ADB_COMMANDS})) - # subcommand not handled + (*:adb-*) _default ;; (*) _arguments \ - '(-d -e)-s["serial"]: :_adb_device_serial' \ - '(-s -e)-d["device"]' \ - '(-d -s)-e["emulator"]' \ - '*:"options":_adb_options_handler' + '(-d -e)-s[serial]: :_adb_device_serial' \ + '(-s -e)-d[device]' \ + '(-d -s)-e[emulator]' \ + '*:options:_adb_options_handler' ;; esac } @@ -159,7 +158,7 @@ _adb_sanitize_context () { done ##expand unquoted to remove sparse elements mywords=( ${mywords[@]} ) - curcontext="${curcontext}${mywords[-1]}" + (( $#mywords )) && curcontext="${curcontext%:*}-${mywords[-1]}:" } (( $+functions[_adb_device_specification] )) || @@ -203,7 +202,7 @@ _adb_dispatch_shell () { (( $+functions[_adb_package_manager_handler] )) && _adb_package_manager_handler ;; (*) - _arguments '*:adb_remote_folder:_adb_remote_folder' + _arguments '*: :_adb_remote_folder' ;; esac } @@ -328,8 +327,8 @@ _adb_dispatch_uninstall () { fi _arguments \ - '-k["keep data and cache"]' \ - '*:"installed package":_adb_installed_packages' + '-k[keep data and cache]' \ + '*:installed package:_adb_installed_packages' } (( $+functions[_adb_dispatch_install] )) || @@ -342,10 +341,10 @@ _adb_dispatch_install () { fi _arguments \ - '-l["forward lock"]' \ - '-r["reinstall"]' \ - '-s["install on sd"]' \ - '*:"select apk file":_path_files -g "*(/)|*.apk"' + '-l[forward lock]' \ + '-r[reinstall]' \ + '-s[install on sd]' \ + '*:apk file:_path_files -g "*(/)|*.apk"' } (( $+functions[_adb_dispatch_push] )) || @@ -357,9 +356,9 @@ _adb_dispatch_push () { fi if [[ ${#words} -gt 2 ]] then - _arguments '*:adb_remote_folder:_adb_remote_folder' + _arguments '*: :_adb_remote_folder' else - _arguments '*:"local file/folder":_files' + _arguments '*:local file/folder:_files' fi } @@ -372,9 +371,9 @@ _adb_dispatch_pull () { fi if [[ ${#words} -gt 2 ]] then - _arguments '*:"local file/folder":_files' + _arguments '*:local file/folder:_files' else - _arguments '*:adb_remote_folder:_adb_remote_folder' + _arguments '*: :_adb_remote_folder' fi } @@ -465,11 +464,6 @@ _adb_shell_commands_handler() { _wanted adb_shell_commands expl 'adb shell commands' compadd ls pm am mkdir rmdir rm cat } -(( $+functions[_adb_any_device_available] )) || -_adb_any_device_available() { - _any_device_available=${#$(adb devices | sed -n 's/^\([^[:space:]]*\)\t.*$/\1/p')} -} - (( $+functions[_adb_device_available] )) || _adb_device_available() { [[ $(adb ${=ADB_DEVICE_SPECIFICATION} get-state 2>&1) == "device" ]] && return 0 @@ -478,22 +472,16 @@ _adb_device_available() { (( $+functions[_adb_full_folder_scan] )) || _adb_full_folder_scan() { - local -a rv; - rv=( ${$(adb ${=ADB_DEVICE_SPECIFICATION} shell 'for i in $(ls -d /*) + filesystem_content=( ${${(f)"$(adb ${=ADB_DEVICE_SPECIFICATION} shell 'cd /;for i in * do case $i in - /proc|/sys|/acct) + proc|sys|acct) ;; *) - ls -R $i + find $i 2> /dev/null ;; esac - done' )//'$\r'/} ) - for line in ${rv[@]}; - do - [[ ${line[1]} == '/' ]] && folder="${line%:}" && adb_device_folders+=$folder && continue; - adb_device_folders+=$folder/$line; - done + done' )"}%$'\r'} ) } (( $+functions[_adb_remote_folder] )) || @@ -503,14 +491,11 @@ _adb_remote_folder () { if [[ -z "$update_policy" ]]; then zstyle ":completion:${curcontext}:" cache-policy _adb_cache_policy_daily fi - local cacheid=package_cache_${$(adb ${=ADB_DEVICE_SPECIFICATION} get-serialno)} + local cacheid=folder_cache_${$(adb ${=ADB_DEVICE_SPECIFICATION} get-serialno)} typeset -a filesystem_content if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" then - local -a adb_device_folders _adb_full_folder_scan - # remove any duplicates and the initial slash => should still remove bare folders from it when it has children - filesystem_content=( ${(u)adb_device_folders#/} ) _store_cache "$cacheid" filesystem_content fi _adb_device_available && \ -- 2.6.1