Suppose I have following files and directories:
% ls
bui00293 buiawer builds/ buiowpe/
I want to list the content of builds
% ls bui[TAB]
Zsh however shows the options with all the files and dirs above. What I want is the autocompletion of zsh's cd
command ie. only autocomplete with directory names.
Best Answer
If you always want to complete directory names only for
ls
, you can put this in your.zshrc
:You can do fancier stuff with the “new” completion system (initialized by
compinit
) by playing with styles. Depending on your options, you may need tounalias ls
. Then, to only ever complete directories on thels
command line:You can complete only directories by default, but complete any file name if no directory matches:
You can also define a key binding to complete only directories, which you can then use anywhere.