about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Type/_files17
-rw-r--r--Completion/Zsh/Command/_zstyle1
2 files changed, 18 insertions, 0 deletions
diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index a3545cb54..4615a60e7 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -39,6 +39,23 @@ if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
       pats=( "$pats[@]" " ${i}:files " )
     fi
   done
+elif zstyle -t ":completion:${curcontext}:" list-dirs-first; then
+  if [[ "$type" = *g* ]]; then
+
+    # add `^-/' after `#q' glob qualifier if not there already
+    if [[ "$glob" = (#b)(*\(\#q)(*\)) ]]; then
+      [[ $match[2] != \^-/* ]] &&
+      glob="${match[1]}^-/,${match[2]}"
+    else
+      glob="$glob(#q^-/)"
+    fi
+
+    pats=( " *(-/):directories:directories ${glob//:/\\:}:globbed-files" )
+  elif [[ "$type" = */* ]] then
+    pats=( '*(-/):directories ' '*:all-files ' )
+  else
+    pats=( '*(-/):directories:directories *(^-/):other-files ' )
+  fi
 else
   if [[ "$type" = *g* ]]; then
 
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index 04845fd5a..008061978 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -74,6 +74,7 @@ styles=(
   last-prompt		 c:bool
   list			 ce:listwhen
   list-colors		 c:
+  list-dirs-first	 c:bool
   list-grouped		 c:bool
   list-packed		 c:bool
   list-prompt            c: