In zsh
, if I type vim *.txt
then Tab, it expands to vim f1.txt f2.txt f3.txt
.
How can I make it show a completion menu listing files matching the pattern, so I can select a single file?
% PS1='%% ' exec zsh -f
% autoload -U compinit && compinit
% setopt GLOB_COMPLETE
% touch aa ab ac ad
% vim a*
Will cycle through the options; and then for a menu (on, like, everything)
% zstyle ':completion*:default' menu 'select=0'
% vim a*
For more information see zshoptions(1)
and the "From Bash to Z Shell" book for slightly readable docs on the completion system.
Menu completion on demand would require a custom widget:
function blaah {
local revert
revert=0
if [[ $options[(k)globcomplete] = off ]]; then
setopt globcomplete
revert=1
fi
zle menu-expand-or-complete
if [[ $revert -eq 1 ]]; then
unsetopt globcomplete
fi
}
zle -N blaah
# or perhaps additionally 'vicmd' or instead 'emacs', depending
binkey -M viins "^W" blaah