mirror of
https://github.com/denisidoro/navi
synced 2024-12-04 01:09:19 +00:00
mvp.
This commit is contained in:
parent
52e90ad8f9
commit
071969ada0
4 changed files with 38 additions and 0 deletions
34
shell/navi.plugin.nu
Normal file
34
shell/navi.plugin.nu
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
export def navi_widget [] {
|
||||||
|
let current_input = (commandline)
|
||||||
|
let last_command = ($current_input | navi fn widget::last_command | str trim)
|
||||||
|
|
||||||
|
match ($last_command | is-empty) {
|
||||||
|
true => {^navi --print | complete | get "stdout"}
|
||||||
|
false => {
|
||||||
|
let find = $"($last_command)_NAVIEND"
|
||||||
|
let replacement = (^navi --print --query $'($last_command)' | complete | get "stdout")
|
||||||
|
|
||||||
|
match ($replacement | str trim | is-empty) {
|
||||||
|
false => {$"($current_input)_NAVIEND" | str replace $find $replacement}
|
||||||
|
true => $current_input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| str trim
|
||||||
|
| commandline edit --replace $in
|
||||||
|
|
||||||
|
commandline set-cursor --end
|
||||||
|
}
|
||||||
|
|
||||||
|
let nav_keybinding = {
|
||||||
|
name: "navi",
|
||||||
|
modifier: control,
|
||||||
|
keycode: char_g,
|
||||||
|
mode: [emacs, vi_normal, vi_insert],
|
||||||
|
event: {
|
||||||
|
send: executehostcommand,
|
||||||
|
cmd: navi_widget,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$env.config.keybindings = ($env.config.keybindings | append $nav_keybinding)
|
|
@ -13,6 +13,7 @@ impl Display for Shell {
|
||||||
Self::Zsh => "zsh",
|
Self::Zsh => "zsh",
|
||||||
Self::Fish => "fish",
|
Self::Fish => "fish",
|
||||||
Self::Elvish => "elvish",
|
Self::Elvish => "elvish",
|
||||||
|
Self::Nushell => "nushell",
|
||||||
};
|
};
|
||||||
|
|
||||||
write!(f, "{s}")
|
write!(f, "{s}")
|
||||||
|
@ -34,6 +35,7 @@ impl Runnable for Input {
|
||||||
Shell::Zsh => include_str!("../../shell/navi.plugin.zsh"),
|
Shell::Zsh => include_str!("../../shell/navi.plugin.zsh"),
|
||||||
Shell::Fish => include_str!("../../shell/navi.plugin.fish"),
|
Shell::Fish => include_str!("../../shell/navi.plugin.fish"),
|
||||||
Shell::Elvish => include_str!("../../shell/navi.plugin.elv"),
|
Shell::Elvish => include_str!("../../shell/navi.plugin.elv"),
|
||||||
|
Shell::Nushell => include_str!("../../shell/navi.plugin.nu"),
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{content}");
|
println!("{content}");
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub enum Shell {
|
||||||
Zsh,
|
Zsh,
|
||||||
Fish,
|
Fish,
|
||||||
Elvish,
|
Elvish,
|
||||||
|
Nushell
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
|
|
@ -159,6 +159,7 @@ test::run "bash" _navi_widget "bash"
|
||||||
test::run "zsh" _navi_widget "zsh"
|
test::run "zsh" _navi_widget "zsh"
|
||||||
test::run "fish" _navi_widget "fish"
|
test::run "fish" _navi_widget "fish"
|
||||||
test::run "elvish" _navi_widget "elvish"
|
test::run "elvish" _navi_widget "elvish"
|
||||||
|
test::run "nu" _navi_widget "nushell"
|
||||||
|
|
||||||
test::set_suite "3rd party"
|
test::set_suite "3rd party"
|
||||||
test::run "tldr" _navi_tldr
|
test::run "tldr" _navi_tldr
|
||||||
|
|
Loading…
Reference in a new issue