diff --git a/home/features/cli/nushell.nix b/home/features/cli/nushell.nix index a7b8ada..f25b870 100644 --- a/home/features/cli/nushell.nix +++ b/home/features/cli/nushell.nix @@ -35,8 +35,6 @@ in { $env.FLAKE = $"($env.HOME)/p/nixos/nixos-config" ''; configFile.text = '' - #source /run/agenix/${config.home.username}-secrets - if (tty) == "/dev/tty1" { exec uwsm start -S -F /run/current-system/sw/bin/Hyprland } @@ -74,7 +72,65 @@ in { alias vi = nvim alias vim = nvim - def h [] { ^nu -c (history | get command | uniq | sk) } + def history_fuzzy [] { + let selected = ( + history + | uniq + | get command + | sk --height 40% --layout=reverse --color=fg:#f8f8f2,bg:#282a36,current_bg:#ff79c6,current_fg:#bd93f9,info:#ffb86c,marker:#6272a4,pointer:#50fa7b,spinner:#50fa7b + ) + if ($selected | is-not-empty) { + ^nu -c ($selected) + } else { + null + } + } + def find_fuzzy [] { + # Find non-hidden text files with matches for any content and select one via fuzzy search + let selected = ( + ^fd --type file --no-hidden -X rg -l --files-with-matches . + | lines + | sk --format { $in } + --height 40% + --layout=reverse + --preview { open $in | bat --color=always --line-range :50 } + --color=fg:#f8f8f2,bg:#282a36,current_bg:#ff79c6,current_fg:#bd93f9,info:#ffb86c,marker:#6272a4,pointer:#50fa7b,spinner:##50fa7b + ) + + # Open the selected file in the default editor if a selection was made + if ($selected | is-not-empty) { + ^$env.EDITOR $selected + } + } + + $env.config = { + keybindings: [ + { + name: history_fuzzy + modifier: control + keycode: char_r + mode: [emacs, vi_insert, vi_normal] + event: [ + { + send: executehostcommand + cmd: "history_fuzzy" + } + ] + } + { + name: history_fuzzy + modifier: control + keycode: char_t + mode: [emacs, vi_insert, vi_normal] + event: [ + { + send: executehostcommand + cmd: "find_fuzzy" + } + ] + } + ] + } ''; }; }; diff --git a/secrets/m3tam3re-secrets.age b/secrets/m3tam3re-secrets.age index dd69bad..acfef71 100644 Binary files a/secrets/m3tam3re-secrets.age and b/secrets/m3tam3re-secrets.age differ