zsh-users
 help / color / mirror / code / Atom feed
* Can't complete path with hidden .zfs?
@ 2017-05-18  3:44 ` lilydjwg
  2017-05-18  9:02   ` Peter Stephenson
  0 siblings, 1 reply; 7+ messages in thread
From: lilydjwg @ 2017-05-18  3:44 UTC (permalink / raw)
  To: zsh-users

Hi there,

When I try to complete path like /zpool/.zfs/snap<Tab> or further, zsh
shows there are "No Matches Found" even there actually are.

The .zfs directory is special in zfs: it doesn't appear in "ls" but if you
access it, it is there. But zsh doesn't complete any path beneath it.

-- 
Best regards,
lilydjwg


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

* Re: Can't complete path with hidden .zfs?
  2017-05-18  3:44 ` Can't complete path with hidden .zfs? lilydjwg
@ 2017-05-18  9:02   ` Peter Stephenson
  2017-05-19  3:38     ` lilydjwg
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 2017-05-18  9:02 UTC (permalink / raw)
  To: zsh-users; +Cc: lilydjwg

On Thu, 18 May 2017 11:44:52 +0800
lilydjwg <lilydjwg@gmail.com> wrote:
> When I try to complete path like /zpool/.zfs/snap<Tab> or further, zsh
> shows there are "No Matches Found" even there actually are.
> 
> The .zfs directory is special in zfs: it doesn't appear in "ls" but if you
> access it, it is there. But zsh doesn't complete any path beneath it.

Try:

zstyle ':completion:*' accept-exact-dirs true

The trade off is in path completion:

  ls /usr/l/bin/<TAB>

will usually allow "l" to complete to "local".  With the setting above,
it won't do that if the directory "l" already exists, it'll just blindly
accept it.  I happen to prefer it that way anyway.

pws


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

* Re: Can't complete path with hidden .zfs?
  2017-05-18  9:02   ` Peter Stephenson
@ 2017-05-19  3:38     ` lilydjwg
  2017-05-19  8:30       ` Peter Stephenson
  0 siblings, 1 reply; 7+ messages in thread
From: lilydjwg @ 2017-05-19  3:38 UTC (permalink / raw)
  To: zsh-users

On Thu, May 18, 2017 at 10:02:20AM +0100, Peter Stephenson wrote:
> On Thu, 18 May 2017 11:44:52 +0800
> lilydjwg <lilydjwg@gmail.com> wrote:
> > When I try to complete path like /zpool/.zfs/snap<Tab> or further, zsh
> > shows there are "No Matches Found" even there actually are.
> > 
> > The .zfs directory is special in zfs: it doesn't appear in "ls" but if you
> > access it, it is there. But zsh doesn't complete any path beneath it.
> 
> Try:
> 
> zstyle ':completion:*' accept-exact-dirs true
> 
> The trade off is in path completion:
> 
>   ls /usr/l/bin/<TAB>
> 
> will usually allow "l" to complete to "local".  With the setting above,
> it won't do that if the directory "l" already exists, it'll just blindly
> accept it.  I happen to prefer it that way anyway.

It works, thanks!

-- 
Best regards,
lilydjwg


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

* Re: Can't complete path with hidden .zfs?
  2017-05-19  3:38     ` lilydjwg
@ 2017-05-19  8:30       ` Peter Stephenson
  2017-05-24 10:41         ` lilydjwg
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 2017-05-19  8:30 UTC (permalink / raw)
  To: zsh-users

On Fri, 19 May 2017 11:38:09 +0800
lilydjwg <lilydjwg@gmail.com> wrote:
> On Thu, May 18, 2017 at 10:02:20AM +0100, Peter Stephenson wrote:
> > zstyle ':completion:*' accept-exact-dirs true
> 
> It works, thanks!

Here's some improved documentation about the cases in question.

pws

diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 2a112ed..ec1809f 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1158,6 +1158,12 @@ directory is accepted without any attempt to complete it further.
 Hence, in the given example, the path tt(/usr/bin/) is accepted
 immediately and completion tried in that directory.
 
+This style is also useful when completing after directories that
+magically appear when referenced, such as ZFS tt(.zfs) directories
+or NetApp tt(.snapshot) directories.  When the style is set the
+shell does not check for the existence of the directory within the
+parent directory.
+
 If you wish to inhibit this behaviour entirely, set the tt(path-completion)
 style (see below) to `false'.
 )
@@ -1428,9 +1434,10 @@ or colons in var(dir) should be quoted with a backslash to be treated
 literally.
 
 This can be useful on systems that support special file systems whose
-top-level pathnames can not be listed or generated with glob patterns.
-It can also be used for directories for which one does not have read
-permission.
+top-level pathnames can not be listed or generated with glob patterns
+(but see tt(accept-exact-dirs) for a more general way of dealing
+with this problem).  It can also be used for directories for which one
+does not have read permission.
 
 The pattern form can be used to add a certain `magic' entry
 to all directories on a particular file system.


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

* Re: Can't complete path with hidden .zfs?
  2017-05-19  8:30       ` Peter Stephenson
@ 2017-05-24 10:41         ` lilydjwg
  2017-05-24 19:03           ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: lilydjwg @ 2017-05-24 10:41 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

On Fri, May 19, 2017 at 09:30:52AM +0100, Peter Stephenson wrote:
> Here's some improved documentation about the cases in question.
> [...]
> @@ -1428,9 +1434,10 @@ or colons in var(dir) should be quoted with a backslash to be treated
>  literally.
>  
>  This can be useful on systems that support special file systems whose
> -top-level pathnames can not be listed or generated with glob patterns.
> -It can also be used for directories for which one does not have read
> -permission.
> +top-level pathnames can not be listed or generated with glob patterns
> +(but see tt(accept-exact-dirs) for a more general way of dealing
> +with this problem).  It can also be used for directories for which one
> +does not have read permission.
>  
>  The pattern form can be used to add a certain `magic' entry
>  to all directories on a particular file system.

Thanks. But with fake-files, I have to list all paths that are root of
a zfs "filesystem". It isn't going to be easy to maintain, so I prefer
accept-exact-dirs.

It'll be great if I can use a custom function to decide what to add, so
I can add .zfs only when it actually exists.

-- 
Best regards,
lilydjwg


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

* Re: Can't complete path with hidden .zfs?
  2017-05-24 10:41         ` lilydjwg
@ 2017-05-24 19:03           ` Bart Schaefer
  2017-05-25  6:35             ` lilydjwg
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2017-05-24 19:03 UTC (permalink / raw)
  To: zsh-users, zsh-users

On May 24,  6:41pm, lilydjwg wrote:
}
} It'll be great if I can use a custom function to decide what to add, so
} I can add .zfs only when it actually exists.

There are two ways you can go here.

If the .zfs mappings don't change very often, you can test at the time
your .zshrc etc. are read and assign to fake-files at that time.

On the other hand if either they change during your shell session or
the check for them is very inexpensive, you can use "zstyle -e" to
have a command executed every time the style is looked up.


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

* Re: Can't complete path with hidden .zfs?
  2017-05-24 19:03           ` Bart Schaefer
@ 2017-05-25  6:35             ` lilydjwg
  0 siblings, 0 replies; 7+ messages in thread
From: lilydjwg @ 2017-05-25  6:35 UTC (permalink / raw)
  To: zsh-users

On Wed, May 24, 2017 at 12:03:40PM -0700, Bart Schaefer wrote:
> On May 24,  6:41pm, lilydjwg wrote:
> }
> } It'll be great if I can use a custom function to decide what to add, so
> } I can add .zfs only when it actually exists.
> 
> There are two ways you can go here.
> 
> If the .zfs mappings don't change very often, you can test at the time
> your .zshrc etc. are read and assign to fake-files at that time.
> 
> On the other hand if either they change during your shell session or
> the check for them is very inexpensive, you can use "zstyle -e" to
> have a command executed every time the style is looked up.

Thanks you so much! I've got it to work perfectly now:

_get_zfs_fake_files () {
  reply=($(awk -vOFS=: -vORS=' ' '$9 == "zfs" { print $5, ".zfs" }' /proc/self/mountinfo))
}
zstyle -e ':completion:*' fake-files _get_zfs_fake_files

They do change often, because some of them are on one of my external
hard drivers.

-- 
Best regards,
lilydjwg


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

end of thread, other threads:[~2017-05-25  6:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170518034638epcas3p184182faf0a2f6197f34386a052b7c856@epcas3p1.samsung.com>
2017-05-18  3:44 ` Can't complete path with hidden .zfs? lilydjwg
2017-05-18  9:02   ` Peter Stephenson
2017-05-19  3:38     ` lilydjwg
2017-05-19  8:30       ` Peter Stephenson
2017-05-24 10:41         ` lilydjwg
2017-05-24 19:03           ` Bart Schaefer
2017-05-25  6:35             ` lilydjwg

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