Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _adb: Just check current dir instead of recursively
- X-seq: zsh-workers 38187
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: _adb: Just check current dir instead of recursively
- Date: Sat, 19 Mar 2016 19:01:04 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=BjgOQPGNIY58KSTJZOqPnJXMlT65dXgvmzPLMbcA7nM=; b=WFXqad6xaU22JWLKJ49wkTGloia9+eHwZYKM20o9zFZXTxR2LiaTqc6A8MOeyf+AeW 6xHcpjB/Lp4YGbETrN6W5FlODXA77dEJbukjIkpInYgtFCer+zrGpxLnWbsPuafAAQV2 1IWWO8x+ItjnUMVe3hq6Oq9yCdXNlR90vpiUVVFr5vs3kub+mu7qQvBKRNcWoMZGkS6j FgjeRAHLH/N3CnvDqwZkmWIxl6zVhhFF/3gW96CYHeIz0Azx5bNEoGd+gaMaAzmXcvhq rOgQO3W2lcL46AMzRjonSJSJte49rVY3x2rgv1XlE9Jj6tMqdMZD+IlW56qw7N5Hu6zP wcqA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
So while the previous patch was an improvement in theory, in practice it
seems most android installs don't in fact have 'find'. Or 'printf'. So
this reimplements the remote completion to not do a recursive cached
listing, and just list the current directory instead.
---
Completion/Unix/Command/_adb | 38 ++++++++++++--------------------------
1 file changed, 12 insertions(+), 26 deletions(-)
diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb
index c0a2bb2..377d1da 100644
--- a/Completion/Unix/Command/_adb
+++ b/Completion/Unix/Command/_adb
@@ -470,40 +470,26 @@ _adb_device_available() {
return 1
}
-(( $+functions[_adb_full_folder_scan] )) ||
-_adb_full_folder_scan() {
- filesystem_content=( ${${(f)"$(adb ${=ADB_DEVICE_SPECIFICATION} shell 'cd /;for i in *
- do
- case $i in
- proc|sys|acct)
- ;;
- *)
- find $i 2> /dev/null
- ;;
- esac
- done' )"}%$'\r'} )
-}
-
(( $+functions[_adb_remote_folder] )) ||
_adb_remote_folder () {
- local expl
- zstyle -s ":completion:${curcontext}:" cache-policy update_policy
- if [[ -z "$update_policy" ]]; then
- zstyle ":completion:${curcontext}:" cache-policy _adb_cache_policy_daily
- fi
- local cacheid=folder_cache_${$(adb ${=ADB_DEVICE_SPECIFICATION} get-serialno)}
- typeset -a filesystem_content
- if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
- then
- _adb_full_folder_scan
- _store_cache "$cacheid" filesystem_content
+ typeset -a files dirs
+ local pref=${PREFIX}
+ if [[ $pref != */* ]]; then
+ pref=
+ elif [[ $pref != */ ]]; then
+ pref=${pref%/*}/
fi
+ # yes, this ls is sickening to look at, but android doesn't have printf or find
+ files=(${${(f)"$(adb ${=ADB_DEVICE_SPECIFICATION} shell 'ls -d 2> /dev/null '$pref'*/ '$pref'*')"}%$'\r'})
+ dirs=(${${(M)files:#*/}%/})
+ files=(${${files:|dirs}:#*\*(/|)})
_adb_device_available && \
- _wanted adb_remote_folder expl 'file/folder on device' _multi_parts $@ -i / filesystem_content
+ _wanted adb_remote_folder expl 'file/folder on device' _multi_parts $@ / files
}
(( $+functions[_adb_installed_packages] )) ||
_adb_installed_packages() {
+ local update_policy
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
if [[ -z "$update_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy _adb_cache_policy_single_command
--
2.6.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author