* [PATCH] zstat completion
@ 2017-10-07 1:23 Daniel Shahaf
0 siblings, 0 replies; only message in thread
From: Daniel Shahaf @ 2017-10-07 1:23 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 79 bytes --]
Attached. It's relying on the auto-description style for -F.
Thanks,
Daniel
[-- Attachment #2: 0001-_stat-Only-complete-stat-if-it-s-provided-by-the-zsh.patch --]
[-- Type: text/x-diff, Size: 1085 bytes --]
>From 0fe0101f5c13fc12e05e9687d0553518c85f1956 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Sat, 7 Oct 2017 00:27:01 +0000
Subject: [PATCH 1/2] _stat: Only complete 'stat' if it's provided by the
zsh/stat builtin.
---
Completion/Zsh/Command/_stat | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/Completion/Zsh/Command/_stat b/Completion/Zsh/Command/_stat
index 03e42e3af..303775b23 100644
--- a/Completion/Zsh/Command/_stat
+++ b/Completion/Zsh/Command/_stat
@@ -4,7 +4,10 @@ local expl ret=1
if [[ "$words[CURRENT-1]" = -[AH] ]]; then
_arrays
-else
+elif [[ $service == zstat ]] ||
+ (( ${+builtins[stat]} )) ||
+ { (( ! ${+builtins} )) && [[ $(type -w stat) == '*: builtin' ]] }
+then
_tags files options || return 1
while _tags; do
@@ -17,4 +20,8 @@ else
+size +atime +mtime +ctime +blksize +block +link
(( ret )) || return 0
done
+else
+ # TODO: system-specific completion
+ # TODO: choose this codepath if 'command stat ...' or '=stat ...' is used
+ _files
fi
[-- Attachment #3: 0002-_stat-Complete-x-options-to-zsh-stat-s-zstat.patch --]
[-- Type: text/x-diff, Size: 2395 bytes --]
>From a86ef493ad526dce91a24c3005de089e200f0d81 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Sat, 7 Oct 2017 01:03:18 +0000
Subject: [PATCH 2/2] _stat: Complete -x options to zsh/stat's 'zstat'.
---
Completion/Zsh/Command/_stat | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/Completion/Zsh/Command/_stat b/Completion/Zsh/Command/_stat
index 303775b23..73bbef471 100644
--- a/Completion/Zsh/Command/_stat
+++ b/Completion/Zsh/Command/_stat
@@ -2,24 +2,30 @@
local expl ret=1
-if [[ "$words[CURRENT-1]" = -[AH] ]]; then
- _arrays
-elif [[ $service == zstat ]] ||
+if [[ $service == zstat ]] ||
(( ${+builtins[stat]} )) ||
{ (( ! ${+builtins} )) && [[ $(type -w stat) == '*: builtin' ]] }
then
- _tags files options || return 1
-
- while _tags; do
- _requested files && _files && ret=0
- _requested options &&
- { ! zstyle -T ":completion:${curcontext}:options" prefix-needed ||
- [[ "$PREFIX[1]" = + || ret -eq 1 ]] } &&
- _all_labels options expl 'inode element' \
- compadd - +device +inode +mode +nlink +uid +gid +rdev \
- +size +atime +mtime +ctime +blksize +block +link
- (( ret )) || return 0
- done
+ _arguments -s -S : \
+ '(-H)-A[assign the results to array, don'\''t print]:array variable:_parameters -g "*array*"' \
+ - set1 \
+ +device +inode +mode +nlink +uid +gid +rdev \
+ +size +atime +mtime +ctime +blksize +block +link \
+ '(-A)-H[assign the results to associative array, don'\''t print]:associative array variable:_parameters -g "*association*"' \
+ '(:)-f[stat a file descriptor]:file descriptor:_file_descriptors' \
+ '(-s)-F:strftime(3) format string:_date_formats zsh' \
+ '(-s)-g[show times in GMT/UTC]' \
+ '-L[don'\''t dereference symbolic links; use lstat(2)]' \
+ '(-N)-n[always show names of files]' \
+ '(-n)-N[never show names of files]' \
+ '-o[print file modes in octal rather than decimal]' \
+ '-r[print raw data]' \
+ '-s[print mode,uid,gid and times as strings]' \
+ '(-T)-t[always show type names]' \
+ '(-t)-T[never show type names]' \
+ '*:files to stat:_files' \
+ - set2 \
+ '-l[list stat types]'
else
# TODO: system-specific completion
# TODO: choose this codepath if 'command stat ...' or '=stat ...' is used
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-10-07 1:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-07 1:23 [PATCH] zstat completion Daniel Shahaf
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).