From b984ba4cf1ec65c5a3c31843efa00f65b3fbed62 Mon Sep 17 00:00:00 2001 From: traxys Date: Mon, 26 Aug 2024 11:14:49 +0200 Subject: [PATCH] minimal: Implement oh-my-zsh like experience for completion --- flake.lock | 17 +++++++++++++++++ flake.nix | 4 ++++ minimal/hm.nix | 12 ++++++++++++ 3 files changed, 33 insertions(+) diff --git a/flake.lock b/flake.lock index 1374d5e..507d8ed 100644 --- a/flake.lock +++ b/flake.lock @@ -1502,6 +1502,7 @@ "treefmt-nix": "treefmt-nix_3", "vim-headerguard": "vim-headerguard", "wiki.vim": "wiki.vim", + "zsh-history-substring-search": "zsh-history-substring-search", "zsh-nix-shell": "zsh-nix-shell" } }, @@ -2045,6 +2046,22 @@ "type": "github" } }, + "zsh-history-substring-search": { + "flake": false, + "locked": { + "lastModified": 1717563893, + "narHash": "sha256-1+w0AeVJtu1EK5iNVwk3loenFuIyVlQmlw8TWliHZGI=", + "owner": "zsh-users", + "repo": "zsh-history-substring-search", + "rev": "87ce96b1862928d84b1afe7c173316614b30e301", + "type": "github" + }, + "original": { + "owner": "zsh-users", + "repo": "zsh-history-substring-search", + "type": "github" + } + }, "zsh-nix-shell": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 6f09a5e..4d719a8 100644 --- a/flake.nix +++ b/flake.nix @@ -81,6 +81,10 @@ url = "github:zdharma-continuum/fast-syntax-highlighting"; flake = false; }; + zsh-history-substring-search = { + url = "github:zsh-users/zsh-history-substring-search"; + flake = false; + }; jq-zsh-plugin = { url = "github:reegnz/jq-zsh-plugin"; flake = false; diff --git a/minimal/hm.nix b/minimal/hm.nix index 5c32369..b76a0a0 100644 --- a/minimal/hm.nix +++ b/minimal/hm.nix @@ -282,7 +282,9 @@ programs.zsh = { enable = true; + enableCompletion = true; + plugins = [ { name = "fast-syntax-highlighting"; @@ -299,6 +301,11 @@ file = "jq.plugin.zsh"; src = inputs.jq-zsh-plugin; } + { + name = "history-substring-search"; + file = "zsh-history-substring-search.zsh"; + src = inputs.zsh-history-substring-search; + } ]; envExtra = "export EDITOR=nvim"; @@ -339,6 +346,11 @@ zmodload zsh/zpty + zstyle ':completion:*' menu select + HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="" + bindkey "^[[A" history-substring-search-up + bindkey "^[[B" history-substring-search-down + ${pkgs.fortune}/bin/fortune \ | ${pkgs.cowsay}/bin/cowsay \ | ${pkgs.dotacat}/bin/dotacat