zsh: completion: make <TAB> with empty input work like ls

This commit is contained in:
Thomas Preisner 2017-07-13 21:03:22 +02:00
parent 1ef55abf90
commit e56aaef60f

View file

@ -20,6 +20,21 @@ unsetopt menu_complete
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
# List all files in the current directory when pressing tab on a empty input,
# behave like complete-word otherwise.
complete-word-or-complete-list-of-files() {
if [[ $#BUFFER == 0 ]]; then
BUFFER='ls '
CURSOR=3
zle list-choices
zle backward-kill-word
else
zle complete-word
fi
}
zle -N complete-word-or-complete-list-of-files
bindkey '^I' complete-word-or-complete-list-of-files
# Fallback to built in ls colors
#zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"