feat(zsh): improve completion behaviour

This commit is contained in:
Felix Schröter 2020-03-14 03:00:16 +01:00
parent f488f772ee
commit cf138810e6
No known key found for this signature in database
GPG key ID: A12D7C9D2FD34458
2 changed files with 18 additions and 0 deletions

View file

@ -27,9 +27,16 @@ in
initExtraBeforeCompInit = with pkgs; ''
source ${zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ${zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh
source ${./first-tab-completion.zsh}
'';
initExtra = ''
zmodload zsh/complist
zstyle ':completion:*' menu select
zstyle ':completion:*' insert-tab false
bindkey '^I' first-tab-completion
bindkey -M menuselect '\e' send-break
bindkey -M menuselect '^[[Z' reverse-menu-complete
setopt histignoredups
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down

View file

@ -0,0 +1,11 @@
first-tab-completion() {
if [[ $#BUFFER == 0 ]]; then
BUFFER="cd "
CURSOR=3
zle list-choices
# zle backward-kill-word # breaks completion
else
zle expand-or-complete
fi
}
zle -N first-tab-completion