zsh-users
 help / color / mirror / code / Atom feed
* Completion does not work with hidden files/directories
@ 2021-05-30 10:39 François RONVAUX
  2021-05-30 12:53 ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: François RONVAUX @ 2021-05-30 10:39 UTC (permalink / raw)
  To: zsh-users

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

Hello gurus of ZSH,


In my home directory, there are currently only hidden files/directories and
the completion mechanism does not see them  :-(

Few examples...

user@hostname [12:07:01]:~ % ls
No matches for: `files'

But if I manualy insert a dot :

user@hostname [12:27:06]:~ % ls .
--==[ files ]==--
.Maildir/   .Xdefaults  .cache/     .config/    .cshrc      .cvsrc
 .local/     .login      .mailrc     .nanorc     .profile    .ssh/
.zsh/


Same issue when I want to change of directory :

user@hostname [12:28:30]:~ % cd
No matches for: `local directory'

user@hostname [12:29:31]:~ % cd .
--==[ local directory ]==--
.Maildir/  .cache/    .config/   .local/    .ssh/      .zsh/


The completion does work fine with not hidden files/directories.
What is wrong with my file "~/.zsh/completion" ?

Note : my machine runs OpenBSD v5.9 with zsh v5.8 ; I do not know if it
matters.

#====================================================
zstyle ':completion:*:*:cd:*' tag-order local-directories path-directories
zstyle ':completion:*' menu select=2
zstyle ':completion:*' select-prompt %SScrolling active: current selection
at %p%s
zstyle ':completion:*:rm:*' ignore-line yes
zstyle ':completion:*:mv:*' ignore-line yes
zstyle ':completion:*:cp:*' ignore-line yes

zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '--==[ %U%B%d%b%u ]==--'
zstyle ':completion:*:messages' format '--==[ %d ]==--'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''

# Color completion.
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-colors 'di=01;34'

# Kill completion.
zstyle ':completion:*:processes' command 'ps -ax'
zstyle ':completion:*:processes-names' command 'ps -aeo comm='
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b)
#([0-9]#)*=0=01;31'
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:*:killall:*:processes-names' list-colors '=(#b)
#([0-9]#)*=0=01;31'
zstyle ':completion:*:*:killall:*' menu yes select

# Partial completion suggestions.
zstyle ':completion:*' list-suffixeszstyle ':completion:*' expand prefix
suffix

# Persistent rehash.
zstyle ':completion:*' rehash true

# Create a cache.
zstyle ':completion:*' cache-path ${ZDOTDIR}/zsh_cache
zstyle ':completion:*' use-cache true #on

autoload -Uz compinit promptinit
compinit
promptinit
#====================================================

Second issue (less important) : the section "Create a cache" in the above
file does not work.


Regards.

[-- Attachment #2: Type: text/html, Size: 3492 bytes --]

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

* Re: Completion does not work with hidden files/directories
  2021-05-30 10:39 Completion does not work with hidden files/directories François RONVAUX
@ 2021-05-30 12:53 ` Oliver Kiddle
  2021-05-31  7:16   ` François RONVAUX
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2021-05-30 12:53 UTC (permalink / raw)
  To: François RONVAUX; +Cc: zsh-users

Fran?ois RONVAUX wrote:
> In my home directory, there are currently only hidden files/directories and the
> completion mechanism does not see them :-(

The main way to control which files are included in file completion is
via the file-patterns style. So if you always want to see hidden files,
it would be something like:

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

(D) is a glob qualifier that includes hidden files and you might use it
from the command-line as, e.g. *.png(D)

I was going to suggest something like the following which adds the (D)
to the all-files fallback:

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

Unfortunately, _files has some sort of shortcut where it does:

  [[ "$pat" = '*' ]] && return ret

So it never tried all-files if globbed-files was using * as a glob. This
should perhaps be looked into and discussed on -workers.

What you can do, however is add a second run of the _complete completer
with the separate file-patterns style:

  zstyle ':completion:*::::' completer _complete _complete:-hidden
  zstyle ':completion:*:complete-hidden:*' file-patterns '%p(D):globbed-files' '*(D):all-files'

Note, however that you likely already have a completer style with other
functions like _expand listed and you should only add _complete:-hidden
to the list somewhere after _complete.

> Same issue when I want to change of directory :

cd doesn't use files so file-patterns may not help there.

> zstyle ':completion:*' cache-path ${ZDOTDIR}/zsh_cache
> zstyle ':completion:*' use-cache true #on

> Second issue (less important) : the section "Create a cache" in the above file
> does not work.

Only some completion functions need to create a cache. Note that those
lines do not create a cache, they only tell completion where to put cache
files. Is ${ZDOTDIR} definitely set to something. If not, it could be
trying /zsh_cache. The directory you specify should already exist and should be a writable directory.

Oliver


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

* Re: Completion does not work with hidden files/directories
  2021-05-30 12:53 ` Oliver Kiddle
@ 2021-05-31  7:16   ` François RONVAUX
  0 siblings, 0 replies; 3+ messages in thread
From: François RONVAUX @ 2021-05-31  7:16 UTC (permalink / raw)
  To: zsh-users

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

Oliver,

Thank you for your reply.

Le dim. 30 mai 2021 à 14:53, Oliver Kiddle <opk@zsh.org> a écrit :

> Fran?ois RONVAUX wrote:
> > In my home directory, there are currently only hidden files/directories
> and the
> > completion mechanism does not see them :-(
>
> The main way to control which files are included in file completion is
> via the file-patterns style. So if you always want to see hidden files,
> it would be something like:
>
>   zstyle ':completion:*' file-patterns '%p(D):globbed-files
> *(D-/):directories' '*(D):all-files'
>
> (D) is a glob qualifier that includes hidden files and you might use it
> from the command-line as, e.g. *.png(D)
>
> I was going to suggest something like the following which adds the (D)
> to the all-files fallback:
>
>   zstyle ':completion:*' file-patterns '%p:globbed-files
> *(-/):directories' '*(D):all-files'
>
> Unfortunately, _files has some sort of shortcut where it does:
>
>   [[ "$pat" = '*' ]] && return ret
>
> So it never tried all-files if globbed-files was using * as a glob. This
> should perhaps be looked into and discussed on -workers.
>
> What you can do, however is add a second run of the _complete completer
> with the separate file-patterns style:
>
>   zstyle ':completion:*::::' completer _complete _complete:-hidden
>   zstyle ':completion:*:complete-hidden:*' file-patterns
> '%p(D):globbed-files' '*(D):all-files'
>
> Note, however that you likely already have a completer style with other
> functions like _expand listed and you should only add _complete:-hidden
> to the list somewhere after _complete.
>
> > Same issue when I want to change of directory :
>
> cd doesn't use files so file-patterns may not help there.
>
> > zstyle ':completion:*' cache-path ${ZDOTDIR}/zsh_cache
> > zstyle ':completion:*' use-cache true #on
>
> > Second issue (less important) : the section "Create a cache" in the
> above file
> > does not work.
>
> Only some completion functions need to create a cache. Note that those
> lines do not create a cache, they only tell completion where to put cache
> files. Is ${ZDOTDIR} definitely set to something. If not, it could be
> trying /zsh_cache. The directory you specify should already exist and
> should be a writable directory.
>
> Oliver
>

[-- Attachment #2: Type: text/html, Size: 2876 bytes --]

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

end of thread, other threads:[~2021-05-31  7:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-30 10:39 Completion does not work with hidden files/directories François RONVAUX
2021-05-30 12:53 ` Oliver Kiddle
2021-05-31  7:16   ` François RONVAUX

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