From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: _adb: fix remote file completion + various fixes
Date: Sat, 19 Mar 2016 13:36:39 +0100 [thread overview]
Message-ID: <1458390999-24565-1-git-send-email-mikachu@gmail.com> (raw)
In-Reply-To: <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
prev parent reply other threads:[~2016-03-19 12:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-18 16:08 PATCH: Fix "35531: fallback on file completion" Mikael Magnusson
2016-03-18 16:11 ` Mikael Magnusson
2016-03-18 23:20 ` Oliver Kiddle
2016-03-19 1:13 ` Mikael Magnusson
2016-03-19 5:56 ` Oliver Kiddle
2016-03-19 12:36 ` Mikael Magnusson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458390999-24565-1-git-send-email-mikachu@gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).