summary refs log tree commit diff
path: root/Completion/Builtins/_stat
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Builtins/_stat')
-rw-r--r--Completion/Builtins/_stat20
1 files changed, 15 insertions, 5 deletions
diff --git a/Completion/Builtins/_stat b/Completion/Builtins/_stat
index 3cdbb2618..5ba06388b 100644
--- a/Completion/Builtins/_stat
+++ b/Completion/Builtins/_stat
@@ -1,10 +1,20 @@
 #compdef stat
 
+local expl ret=1
+
 if [[ "$words[CURRENT-1]" = -[AH] ]]; then
-  compgen -A
+  _arrays
 else
-  [[ "$PREFIX[1]" = + ]] &&
-      compadd - +device +inode +mode +nlink +uid +gid +rdev +size \
-                +atime +mtime +ctime +blksize +block +link
-  _files
+  _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
 fi