zsh-users
 help / color / mirror / code / Atom feed
* completing files first
@ 2013-01-29 17:47 Daniel
  2013-01-30 10:16 ` Jesper Nygårds
  2013-01-30 14:41 ` Mikael Magnusson
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel @ 2013-01-29 17:47 UTC (permalink / raw)
  To: zsh-users

When completing files in the current directory, I generally want it to
pick actual files first (and not directories). I am normally in the
directory where I want to work on a file, so when I do "qiv<TAB>" or
"qiv foo<TAB>" to view some image, I want the files first, and secondly
directories. I knew about group-order, but there seems to be only on
group "files"?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: completing files first
  2013-01-29 17:47 completing files first Daniel
@ 2013-01-30 10:16 ` Jesper Nygårds
  2013-01-30 11:44   ` Daniel
  2013-01-30 14:41 ` Mikael Magnusson
  1 sibling, 1 reply; 8+ messages in thread
From: Jesper Nygårds @ 2013-01-30 10:16 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

Are you using menu-completion? I do, and use this which works well for me:

zstyle ':completion:*' file-patterns '*(-/):directories
%p(^-/):globbed-files' '*:all-files'
zstyle ':completion:*' group-order globbed-files all-files directories




On Tue, Jan 29, 2013 at 6:47 PM, Daniel <quite@hack.org> wrote:

> When completing files in the current directory, I generally want it to
> pick actual files first (and not directories). I am normally in the
> directory where I want to work on a file, so when I do "qiv<TAB>" or
> "qiv foo<TAB>" to view some image, I want the files first, and secondly
> directories. I knew about group-order, but there seems to be only on
> group "files"?
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: completing files first
  2013-01-30 10:16 ` Jesper Nygårds
@ 2013-01-30 11:44   ` Daniel
  2013-01-30 14:42     ` Re[2]: " Manuel Presnitz
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel @ 2013-01-30 11:44 UTC (permalink / raw)
  To: zsh-users

> Are you using menu-completion? I do, and use this which works well for me:
>
> zstyle ':completion:*' file-patterns '*(-/):directories
> %p(^-/):globbed-files' '*:all-files'
> zstyle ':completion:*' group-order globbed-files all-files directories

Yes I use setopt menucomplete

Your example works sometimes. It works with "cat <TAB>" -- I get two
separate groups named "file", the first one with files, the second with
directories. Great!

But if I try with "less <TAB>" I get only one group "file", with files
and directories in a (alphasorted) mix. Likewise it doesn't work on my
own completer "_myview" (see below).

I tried, to no avail, adding some colons and asterices to your zstyle,
hoping to somehow make it more general. Is it somehow possible?


~/.zsh/completion/_myview:

local extns

extns="(bmp|gif|jp([eg]|eg)|png|p[pngb]m|tif(|f)|tga|x[pb]m|asf|asx|avi|flv|m4v|mkv|mov|mpeg|mpg|vob|ts|qt|rm|we
bm|wmv|pdf|ps|epub|mobi|html|htm|rar|zip|tar(|.(gz|bz|bz2|Z|lzo|lz|xz))|cb(r|z))|doc"

_arguments \
  "*:myviewable documents:_files -g '*.(#i)($extns)(-.)'"



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: completing files first
  2013-01-29 17:47 completing files first Daniel
  2013-01-30 10:16 ` Jesper Nygårds
@ 2013-01-30 14:41 ` Mikael Magnusson
       [not found]   ` <20130130144942.GA3384@kelebek.lublin.se>
  2013-01-30 15:04   ` Daniel
  1 sibling, 2 replies; 8+ messages in thread
From: Mikael Magnusson @ 2013-01-30 14:41 UTC (permalink / raw)
  To: Daniel; +Cc: zsh-users

On 29/01/2013, Daniel <quite@hack.org> wrote:
> When completing files in the current directory, I generally want it to
> pick actual files first (and not directories). I am normally in the
> directory where I want to work on a file, so when I do "qiv<TAB>" or
> "qiv foo<TAB>" to view some image, I want the files first, and secondly
> directories. I knew about group-order, but there seems to be only on
> group "files"?

zstyle ':completion:*' list-dirs-first true
then you can probably change the order of these with group-order if you want.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re[2]: completing files first
  2013-01-30 11:44   ` Daniel
@ 2013-01-30 14:42     ` Manuel Presnitz
  2013-01-30 15:07       ` Daniel
  0 siblings, 1 reply; 8+ messages in thread
From: Manuel Presnitz @ 2013-01-30 14:42 UTC (permalink / raw)
  To: zsh-users

Honestly, I do not really understand these zstyle stuff, but combining
Jesper's suggestions with my own .zshrc I found by chance, that

zstyle ':completion:*' file-patterns '*(-/):directories:directories %p(^-/):globbed-files' '*:all-files'

(note the second word ,directories', wchich is just a label, it could also be
something else) instead of

zstyle ':completion:*' file-patterns '*(-/):directories %p(^-/):globbed-files' '*:all-files'

works also with ,less' -- as in your example.



Daniel hat am 30.01.2013 um 11:44 folgendes geschrieben:

> > Are you using menu-completion? I do, and use this which works well
> for me:
> >
> > zstyle ':completion:*' file-patterns '*(-/):directories
> > %p(^-/):globbed-files' '*:all-files'
> > zstyle ':completion:*' group-order globbed-files all-files directories
>
> Yes I use setopt menucomplete
>
> Your example works sometimes. It works with "cat <TAB>" -- I get two
> separate groups named "file", the first one with files, the second with
> directories. Great!
>
> But if I try with "less <TAB>" I get only one group "file", with files
> and directories in a (alphasorted) mix. Likewise it doesn't work on my
> own completer "_myview" (see below).
>
> I tried, to no avail, adding some colons and asterices to your zstyle,
> hoping to somehow make it more general. Is it somehow possible?
>
>
> ~/.zsh/completion/_myview:
>
> local extns
>
> extns="(bmp|gif|jp([eg]|eg)|png|p[pngb]m|tif(|f)|tga|x[pb]m|asf|asx|avi|flv|m4v|mkv|mov|mpeg|mpg|vob|ts|qt|rm|we
> bm|wmv|pdf|ps|epub|mobi|html|htm|rar|zip|tar(|.(gz|bz|bz2|Z|lzo|lz|xz))|cb(r|z))|doc"
>
> _arguments \
>   "*:myviewable documents:_files -g '*.(#i)($extns)(-.)'"




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: completing files first
       [not found]   ` <20130130144942.GA3384@kelebek.lublin.se>
@ 2013-01-30 14:52     ` Mikael Magnusson
  0 siblings, 0 replies; 8+ messages in thread
From: Mikael Magnusson @ 2013-01-30 14:52 UTC (permalink / raw)
  To: Zsh Users

On 30 January 2013 15:49, Daniel <quite@hack.org> wrote:
> On Wed, Jan 30, 2013 at 03:41:20PM +0100, Mikael Magnusson wrote:
>> On 29/01/2013, Daniel <quite@hack.org> wrote:
>> > When completing files in the current directory, I generally want it to
>> > pick actual files first (and not directories). I am normally in the
>> > directory where I want to work on a file, so when I do "qiv<TAB>" or
>> > "qiv foo<TAB>" to view some image, I want the files first, and secondly
>> > directories. I knew about group-order, but there seems to be only on
>> > group "files"?
>>
>> zstyle ':completion:*' list-dirs-first true
>> then you can probably change the order of these with group-order if you want.
>
> Oh thanks, one step further... But, no, the following doesn't cut it...
>
> zstyle ':completion:*' group-order file directories

The tag for files is called other-files when list-dirs-first is enabled.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: completing files first
  2013-01-30 14:41 ` Mikael Magnusson
       [not found]   ` <20130130144942.GA3384@kelebek.lublin.se>
@ 2013-01-30 15:04   ` Daniel
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel @ 2013-01-30 15:04 UTC (permalink / raw)
  To: zsh-users

On 2013-01-30, Mikael Magnusson <mikachu@gmail.com> wrote:
> On 29/01/2013, Daniel <quite@hack.org> wrote:
>> When completing files in the current directory, I generally want it to
>> pick actual files first (and not directories). I am normally in the
>> directory where I want to work on a file, so when I do "qiv<TAB>" or
>> "qiv foo<TAB>" to view some image, I want the files first, and secondly
>> directories. I knew about group-order, but there seems to be only on
>> group "files"?
>
> zstyle ':completion:*' list-dirs-first true
> then you can probably change the order of these with group-order if you want.

This did list directories first, but "group-order file directories" did
not work to order the groups. Perhaps I'm not catching the correct group
with "file"--but that's what I see as the name in the competion menu,
and I do have "group-name ''".


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Re[2]: completing files first
  2013-01-30 14:42     ` Re[2]: " Manuel Presnitz
@ 2013-01-30 15:07       ` Daniel
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel @ 2013-01-30 15:07 UTC (permalink / raw)
  To: zsh-users

On 2013-01-30, Manuel Presnitz <mpy@gmx.net> wrote:
> Honestly, I do not really understand these zstyle stuff, but combining
> Jesper's suggestions with my own .zshrc I found by chance, that
>
> zstyle ':completion:*' file-patterns '*(-/):directories:directories %p(^-/):globbed-files' '*:all-files'
>
> (note the second word ,directories', wchich is just a label, it could also be
> something else) instead of 
>
> zstyle ':completion:*' file-patterns '*(-/):directories %p(^-/):globbed-files' '*:all-files'
>
> works also with ,less' -- as in your example.

Yeah, they are tricky, these zstyles.

Thanks, this led me to try, by pure experimentation, this:

zstyle ':completion:*' file-patterns '*(-/):directories:directories %p(^-/):globbed-files:files' '*:all-files'
zstyle ':completion:*' group-order globbed-files all-files files directories

Which actually does what I want... It ditches the particular names that
completers give its groups, but at least I get them in the order I want.
Works with cat, less and my "myview".


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-01-30 16:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-29 17:47 completing files first Daniel
2013-01-30 10:16 ` Jesper Nygårds
2013-01-30 11:44   ` Daniel
2013-01-30 14:42     ` Re[2]: " Manuel Presnitz
2013-01-30 15:07       ` Daniel
2013-01-30 14:41 ` Mikael Magnusson
     [not found]   ` <20130130144942.GA3384@kelebek.lublin.se>
2013-01-30 14:52     ` Mikael Magnusson
2013-01-30 15:04   ` Daniel

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).