mirror of
https://github.com/denisidoro/navi
synced 2024-11-23 12:03:06 +00:00
34 lines
1,008 B
Text
34 lines
1,008 B
Text
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)
|