zsh: completion: make <TAB> with empty input work like ls
This commit is contained in:
parent
1ef55abf90
commit
e56aaef60f
1 changed files with 15 additions and 0 deletions
|
|
@ -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}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue