From e56aaef60f0bbd2254af9335c24e45a98b70e7ee Mon Sep 17 00:00:00 2001 From: Thomas Preisner Date: Thu, 13 Jul 2017 21:03:22 +0200 Subject: [PATCH] zsh: completion: make with empty input work like ls --- zsh/completion.zsh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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}"