From cf138810e6109115bc85a8ecd0f3fd43c56b5ef7 Mon Sep 17 00:00:00 2001 From: Felix Tenley Date: Sat, 14 Mar 2020 03:00:16 +0100 Subject: [PATCH] feat(zsh): improve completion behaviour --- home/shell/default.nix | 7 +++++++ home/shell/first-tab-completion.zsh | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 home/shell/first-tab-completion.zsh diff --git a/home/shell/default.nix b/home/shell/default.nix index 7c48c90..5967ab9 100644 --- a/home/shell/default.nix +++ b/home/shell/default.nix @@ -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 diff --git a/home/shell/first-tab-completion.zsh b/home/shell/first-tab-completion.zsh new file mode 100644 index 0000000..938aa70 --- /dev/null +++ b/home/shell/first-tab-completion.zsh @@ -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