+skim functions for nushell

This commit is contained in:
m3tam3re 2025-05-04 19:00:11 +02:00
parent 32503965ab
commit 881a65263d
2 changed files with 59 additions and 3 deletions

View File

@ -35,8 +35,6 @@ in {
$env.FLAKE = $"($env.HOME)/p/nixos/nixos-config" $env.FLAKE = $"($env.HOME)/p/nixos/nixos-config"
''; '';
configFile.text = '' configFile.text = ''
#source /run/agenix/${config.home.username}-secrets
if (tty) == "/dev/tty1" { if (tty) == "/dev/tty1" {
exec uwsm start -S -F /run/current-system/sw/bin/Hyprland exec uwsm start -S -F /run/current-system/sw/bin/Hyprland
} }
@ -74,7 +72,65 @@ in {
alias vi = nvim alias vi = nvim
alias vim = 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"
}
]
}
]
}
''; '';
}; };
}; };

Binary file not shown.