nushell dir_fuzzy

This commit is contained in:
m3tam3re 2025-05-05 01:58:36 +02:00
parent 881a65263d
commit 53ce9740bd

View File

@ -43,12 +43,12 @@ in {
} }
alias .. = cd .. alias .. = cd ..
alias ... = cd ../.. alias ... = cd ...
alias h = cd $env.HOME
alias b = yazi alias b = yazi
alias lt = eza --tree --level=2 --long --icons --git alias lt = eza --tree --level=2 --long --icons --git
alias grep = rg alias grep = rg
alias just = just --unstable alias just = just --unstable
alias fs = du -d 1 | sort-by apparent -r
alias n = nix alias n = nix
alias nd = nix develop -c $nu.current-shell alias nd = nix develop -c $nu.current-shell
@ -85,6 +85,13 @@ in {
null null
} }
} }
def --env dir_fuzzy [] {
let selected = (
fd --type directory
| ^sk --preview 'eza --tree --no-permissions --no-filesize --no-user --no-time --only-dirs {}' --height 40% --layout=reverse --color=fg:#f8f8f2,bg:#282a36,current_bg:#ff79c6,current_fg:#bd93f9,info:#ffb86c,marker:#6272a4,pointer:#50fa7b,spinner:#50fa7b
)
cd $selected
}
def find_fuzzy [] { def find_fuzzy [] {
# Find non-hidden text files with matches for any content and select one via fuzzy search # Find non-hidden text files with matches for any content and select one via fuzzy search
let selected = ( let selected = (
@ -96,8 +103,6 @@ in {
--preview { open $in | bat --color=always --line-range :50 } --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 --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) { if ($selected | is-not-empty) {
^$env.EDITOR $selected ^$env.EDITOR $selected
} }
@ -117,6 +122,18 @@ in {
} }
] ]
} }
{
name: dir_fuzzy
modifier: alt
keycode: char_c
mode: [emacs, vi_insert, vi_normal]
event: [
{
send: executehostcommand
cmd: "dir_fuzzy"
}
]
}
{ {
name: history_fuzzy name: history_fuzzy
modifier: control modifier: control