From ce4aad3e048f49dd97199ee61dbfe065e084317b Mon Sep 17 00:00:00 2001 From: Yadunand Prem Date: Sun, 7 Sep 2025 16:12:28 +0800 Subject: [PATCH] Use fzf for history and carapace for completion --- modules/home/nushell/default.nix | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/modules/home/nushell/default.nix b/modules/home/nushell/default.nix index e802731..aad70a6 100644 --- a/modules/home/nushell/default.nix +++ b/modules/home/nushell/default.nix @@ -24,6 +24,39 @@ in $env.config.buffer_editor = "nvim" $env.config.show_banner = false $env.EDITOR = "nvim" + + $env.config.history.file_format = "sqlite" + $env.config.history.max_size = 5_000_000 + + $env.config.keybindings = [ + { + name: fuzzy_history + modifier: control + keycode: char_r + mode: [emacs, vi_normal, vi_insert] + event: [ + { + send: ExecuteHostCommand + cmd: "let result = ( + history + | get command + | uniq + | reverse + | str join (char -i 0) + | fzf --scheme=history + --read0 + --height=40% + --bind=ctrl-r:toggle-sort + --highlight-line + --query=(commandline | str substring 0..(commandline get-cursor)) + +m + | complete + ); if ($result.exit_code == 0) { commandline edit ($result.stdout | str trim) }" + } + ] + } + ]; + ''; shellAliases = { lg = "lazygit"; @@ -34,6 +67,10 @@ in jp = "jj git push"; }; }; + carapace = { + enable = true; + enableNushellIntegration = true; + }; nix-your-shell = { enable = true; enableNushellIntegration = true;