From c0e501d8a53c1bc29f48c1e7cd94d6eb9601bb54 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 21 Aug 2008 15:53:00 +0000 Subject: Alexey I. Froloff: 25459: add list-dirs-first style. Also doc. --- Completion/Unix/Type/_files | 17 +++++++++++++++++ Completion/Zsh/Command/_zstyle | 1 + 2 files changed, 18 insertions(+) (limited to 'Completion') 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: -- cgit 1.4.1