mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-09-11 13:45:56 +03:00
FEATURE: add some fuzzy keybindings (#512)
* add `history`, `directories` and `modules` fuzzy keybindings * add a little README for the bindings
This commit is contained in:
parent
394e625837
commit
c698547b3b
4
custom-menus/fuzzy/README.md
Normal file
4
custom-menus/fuzzy/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
a few keybindings using the new `input list --fuzzy` command to interactively select what to do:
|
||||
- `history.nu`: select a command from history
|
||||
- `directories.nu`: select a directory, recursively from the current `PWD`
|
||||
- `modules.nu`: recursively select and insert a `.nu` module from `NU_LIB_DIRS` inside a `use ...` command, ready to be run by pressing enter
|
16
custom-menus/fuzzy/directory.nu
Normal file
16
custom-menus/fuzzy/directory.nu
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
name: fuzzy_dir
|
||||
modifier: control
|
||||
keycode: char_s
|
||||
mode: [emacs, vi_normal, vi_insert]
|
||||
event: {
|
||||
send: executehostcommand
|
||||
cmd: "commandline -a (
|
||||
ls **/*
|
||||
| where type == dir
|
||||
| get name
|
||||
| input list --fuzzy
|
||||
$'Please choose a (ansi magenta)directory(ansi reset) to (ansi cyan_underline)insert(ansi reset):'
|
||||
)"
|
||||
}
|
||||
}
|
17
custom-menus/fuzzy/history.nu
Normal file
17
custom-menus/fuzzy/history.nu
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
name: fuzzy_history
|
||||
modifier: control
|
||||
keycode: char_h
|
||||
mode: [emacs, vi_normal, vi_insert]
|
||||
event: {
|
||||
send: executehostcommand
|
||||
cmd: "commandline (
|
||||
history
|
||||
| each { |it| $it.command }
|
||||
| uniq
|
||||
| reverse
|
||||
| input list --fuzzy
|
||||
$'Please choose a (ansi magenta)command from history(ansi reset):'
|
||||
)"
|
||||
}
|
||||
}
|
24
custom-menus/fuzzy/modules.nu
Normal file
24
custom-menus/fuzzy/modules.nu
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
name: fuzzy_module
|
||||
modifier: control
|
||||
keycode: char_u
|
||||
mode: [emacs, vi_normal, vi_insert]
|
||||
event: {
|
||||
send: executehostcommand
|
||||
cmd: '
|
||||
commandline --replace "use "
|
||||
commandline --insert (
|
||||
$env.NU_LIB_DIRS
|
||||
| each {|dir|
|
||||
ls ($dir | path join "**" "*.nu")
|
||||
| get name
|
||||
| str replace $dir ""
|
||||
| str trim -c "/"
|
||||
}
|
||||
| flatten
|
||||
| input list --fuzzy
|
||||
$"Please choose a (ansi magenta)module(ansi reset) to (ansi cyan_underline)load(ansi reset):"
|
||||
)
|
||||
'
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user