zsh-workers
 help / color / mirror / code / Atom feed
* Zsh includes directories in tab completion
@ 2019-01-02 14:41 Saverio M.
  2019-01-02 15:35 ` dana
  2019-01-02 15:42 ` Daniel Shahaf
  0 siblings, 2 replies; 3+ messages in thread
From: Saverio M. @ 2019-01-02 14:41 UTC (permalink / raw)
  To: zsh-workers

Hello,

On my system, zsh tab-completion includes directories present in the 
path, in addition to files, which is confusing and error prone.

Is this intended? I think it isn't, but I didn't find a way to disable 
it (there's a lot of documentation around, but the posts I've found talk 
about tab completion customization).

To be specific, I had Oh My Zsh installed, but I've removed it, and I've 
also removed .zshrc to be sure I'm running a vanilla setup.

This is the test case:

```sh
$ echo $ZSH_VERSION
5.4.2

$ echo $ZDOTDIR

$ cat $HOME/.zshenv
cat: /home/myuser/.zshenv: No such file or directory

$ cat $HOME/.zprofile
cat: /home/myuser/.zprofile: No such file or directory

$ cat $HOME/.zshrc
cat: /home/myuser/.zshrc: No such file or directory

$ cat $HOME/.zlogin
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # 
Load RVM into a shell session *as a function*

$ cat $HOME/.zlogout
cat: /home/myuser/.zlogout: No such file or directory

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/myuser/bin:/home/myuser/code/scripts:/home/myuser/.rvm/bin

$ ls -ld $(find ~/code/scripts -name 'myscript*')
drwxr-xr-x 1 myuser myuser  752 Dec  2 18:39 
/home/myuser/code/scripts/myscript
-rwxrwxr-x 1 myuser myuser 4571 Dec  2 18:40 
/home/myuser/code/scripts/myscript.rb

$ myscript<TAB>
myscript     myscript.rb
```

Can anybody shed some light?

Thanks!
Saverio

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

* Re: Zsh includes directories in tab completion
  2019-01-02 14:41 Zsh includes directories in tab completion Saverio M.
@ 2019-01-02 15:35 ` dana
  2019-01-02 15:42 ` Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: dana @ 2019-01-02 15:35 UTC (permalink / raw)
  To: Saverio M.; +Cc: zsh-workers

On 2 Jan 2019, at 08:41, Saverio M. <saverio.pub2@gmail.com> wrote:
>On my system, zsh tab-completion includes directories present in the path, in
>addition to files, which is confusing and error prone.
>
>Is this intended?

Yes, by default the shell doesn't check the types of files it finds in your
PATH, it just hashes them all. You can enable the option hash_executables_only
to change that:

  HASH_EXECUTABLES_ONLY
  When hashing commands because of HASH_CMDS, check that the file to be hashed
  is actually an executable. This option is unset by default as if the path
  contains a large number of commands, or consists of many remote files, the
  additional tests can take a long time. Trial and error is needed to show if
  this option is beneficial.

It makes hashing slower in general, but like it says you'll have to see if
that's bothersome for you.

If you'd rather not do that, and it's only a problem for a few specific files,
you might be able to use the ignored-patterns style instead:

  zstyle ':completion:*:commands' ignored-patterns myscript

dana


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

* Re: Zsh includes directories in tab completion
  2019-01-02 14:41 Zsh includes directories in tab completion Saverio M.
  2019-01-02 15:35 ` dana
@ 2019-01-02 15:42 ` Daniel Shahaf
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2019-01-02 15:42 UTC (permalink / raw)
  To: Saverio M., zsh-workers

Saverio M. wrote on Wed, 02 Jan 2019 15:41 +0100:
> Is this intended? I think it isn't, but I didn't find a way to disable 
> it (there's a lot of documentation around, but the posts I've found talk 
> about tab completion customization).

Yes, it's intended.  You can 'setopt hashexecutablesonly' to disable it.

> $ cat $HOME/.zlogin
> [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # 
> Load RVM into a shell session *as a function*

For future reference, "vanilla" environments don't usually include
random third-party dependencies :)

(The gold standard is 'zsh -f'.)

> $ ls -ld $(find ~/code/scripts -name 'myscript*')

You could have done this with a recursive glob:
.
    % ls -dl ~/code/scripts/**/myscript*

Cheers,

Daniel

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

end of thread, other threads:[~2019-01-02 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-02 14:41 Zsh includes directories in tab completion Saverio M.
2019-01-02 15:35 ` dana
2019-01-02 15:42 ` Daniel Shahaf

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