about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-01-04 15:02:25 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-01-04 15:02:25 +0000
commit01d4ad38356395d4cc47d9972b29d5643673df6f (patch)
tree482a7d08628b2fcd04c016a383938604edcdb5e7 /Completion
parentbf2b2bcce77371871c4e35eda549756c89b62fdc (diff)
downloadzsh-01d4ad38356395d4cc47d9972b29d5643673df6f.tar.gz
zsh-01d4ad38356395d4cc47d9972b29d5643673df6f.tar.xz
zsh-01d4ad38356395d4cc47d9972b29d5643673df6f.zip
zsh-workers/9199
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Core/_path_files33
1 files changed, 32 insertions, 1 deletions
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index 55d0aefa9..415a55acb 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -6,7 +6,7 @@
 local linepath realpath donepath prepath testpath exppath
 local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
 local pats haspats=no ignore group expl addpfx addsfx remsfx
-local nm=$compstate[nmatches] menu match matcher mopts atmp
+local nm=$compstate[nmatches] menu match matcher mopts atmp sort
 
 typeset -U prepaths exppaths
 
@@ -111,6 +111,37 @@ if [[ "$sopt" = - ]]; then
   fi
 fi
 
+if zstyle -s ":completion${curcontext}:files" sort tmp1; then
+  case "$tmp1" in
+  *size*)             sort=oL;;
+  *links*)            sort=ol;;
+  *(time|date|modi)*) sort=om;;
+  *access*)           sort=oa;;
+  *(inode|change)*)   sort=oc;;
+  *)                  sort=on;;
+  esac
+  [[ "$tmp1" = *rev* ]] && sort[1]=O
+
+  if [[ "$sort" = on ]]; then
+    sort=''
+  else
+    group=( "${(@)group/#-J/-V}" )
+    expl=( "${(@)expl/#-J/-V}" )
+
+    tmp2=()
+    for tmp1 in "$pats[@]"; do
+      if [[ "$tmp1" = ?*\(\([^\|~]##\)\) ]]; then
+        tmp2=( "$tmp2[@]" "${tmp1[1,-3]}${sort}))" )
+      elif [[ "$tmp1" = ?*\([^\|~]##\) ]]; then
+        tmp2=( "$tmp2[@]" "${tmp1[1,-2]}${sort})" )
+      else
+        tmp2=( "$tmp2[@]" "${tmp1}(${sort})" )
+      fi
+    done
+    pats=( "$tmp2[@]" )
+  fi
+fi
+
 # We get the prefix and the suffix from the line and save the whole
 # original string. Then we see if we will do menucompletion.