From: "Alexey I. Froloff" <raorn@altlinux.org>
To: zsh workers <zsh-workers@sunsite.dk>
Cc: "Alexey I. Froloff" <raorn@altlinux.org>
Subject: [PATCH] _files: "list-dirs-first" style.
Date: Sat, 16 Aug 2008 11:06:10 +0400 [thread overview]
Message-ID: <1218870370-2651-1-git-send-email-raorn@altlinux.org> (raw)
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 <Tab>
---- 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 <raorn@altlinux.org>
---
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
next reply other threads:[~2008-08-16 7:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-16 7:06 Alexey I. Froloff [this message]
2008-08-18 9:57 ` Alexey I. Froloff
2008-08-21 15:54 ` Peter Stephenson
2008-08-22 20:04 ` Richard Hartmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1218870370-2651-1-git-send-email-raorn@altlinux.org \
--to=raorn@altlinux.org \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).