diff --git a/zsh/completion.zsh b/zsh/completion.zsh index fb0a28e..d9569cc 100644 --- a/zsh/completion.zsh +++ b/zsh/completion.zsh @@ -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}"