From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17419 invoked from network); 16 Aug 2008 07:06:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 16 Aug 2008 07:06:46 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 96638 invoked from network); 16 Aug 2008 07:06:38 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Aug 2008 07:06:38 -0000 Received: (qmail 15087 invoked by alias); 16 Aug 2008 07:06:28 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25459 Received: (qmail 15060 invoked from network); 16 Aug 2008 07:06:23 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 16 Aug 2008 07:06:24 -0000 Received: from mail2.cnt.ru (mail2.cnt.ru [212.15.127.82]) by bifrost.dotsrc.org (Postfix) with ESMTP id C4405805A425 for ; Sat, 16 Aug 2008 09:06:10 +0200 (CEST) Received: from hell.devel.altlinux.ru (unknown [213.85.39.63]) by mail2.cnt.ru (Postfix) with ESMTP id 207FA60655; Sat, 16 Aug 2008 11:06:10 +0400 (MSD) Received: by hell.devel.altlinux.ru (Postfix, from userid 500) id 293333600105; Sat, 16 Aug 2008 11:06:10 +0400 (MSD) From: "Alexey I. Froloff" To: zsh workers Cc: "Alexey I. Froloff" Subject: [PATCH] _files: "list-dirs-first" style. Date: Sat, 16 Aug 2008 11:06:10 +0400 Message-Id: <1218870370-2651-1-git-send-email-raorn@altlinux.org> X-Mailer: git-send-email 1.5.6.5.GIT X-Virus-Scanned: ClamAV 0.92.1/8051/Sat Aug 16 05:44:59 2008 on bifrost X-Virus-Status: Clean When this style set to "true", directories are shown before files. Also instead of "all-files" tag it offers "other-files" bceause directories are excluded from file list. Screenshot: user@host /usr/libexec $ ls ---- directories ---- awk/ ConsoleKit/ dbus-1/ evolution-data-server/ gcc/ gnupg/ gvfs/ hal/ hasher-priv/ PolicyKit/ postfix/ sudo/ X11/ xscreensaver/ ---- files ---- ck-collect-session-info* This can also be done by setting "file-patterns" style to '*(-/):directories:directories %p(^-/):other-files' ("directories" tag description is required to split groups), but completion for "zmodload" command doesn't offer modules. Another possible solution does not work either: zstyle ':completion:*' file-patterns '*(-/):directories:directories %p:other-files' zstyle ':completion:*:other-files' ignored-patterns '*(-/)' "ignored-patterns" seems to be ignored by _path_files... Signed-off-by: Alexey I. Froloff --- Completion/Unix/Type/_files | 17 +++++++++++++++++ Completion/Zsh/Command/_zstyle | 1 + 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files index a3545cb..4615a60 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 2bf2709..a181a7b 100644 --- a/Completion/Zsh/Command/_zstyle +++ b/Completion/Zsh/Command/_zstyle @@ -68,6 +68,7 @@ styles=( last-prompt c:bool list c:listwhen list-colors c: + list-dirs-first c:bool list-grouped c:bool list-packed c:bool list-prompt c: -- 1.5.6.5.GIT