Frage

I've just moved from bash to zsh. It's a great terminal shell, but I'm missing one property - file name completion for non-standard executables.

For example, If ls gives thread_pool_examples and thread_pools:

enter image description here

Then typing du, space and tab would autocomplete the common prefix thread_pool, nd another click will iterate over the options:

enter image description here enter image description here

Clicking Enter will pick the highlighted item.

The problem is that this does not work with my custom scripts. For example, if I run rmf - a Python executable in my path - and click tab, no autocomplete options will appear.

Any ideas how to make zsh autocomplete filenames for every executable?

War es hilfreich?

Lösung

Honestly, IMO something in your shell configuration is breaking things up. Try doing this to verify it:

zsh -f # starts a new shell ignoring your configuration
autoload compinit
compinit
./my-shell-script [TAB]

it completes with files. That is the default.

FWIW, if you want to bind a particular completer to a command/alias etc, you can do

compdef _jstack jstack

# simple _files completion
compdef _files my-local-python-script

# restrict to some file extensions
compdef '_files -g "*.(eps|ps|pdf)"' okular 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top