2022-01-16 13:22:32 +03:00
|
|
|
function _navi_smart_replace
|
2022-01-16 14:06:57 +03:00
|
|
|
set -l current_process (commandline -p | string trim)
|
2021-12-16 20:43:52 +03:00
|
|
|
|
2022-01-16 14:17:28 +03:00
|
|
|
if test -z "$current_process"
|
2022-01-16 14:06:57 +03:00
|
|
|
commandline -i (navi --print)
|
|
|
|
else
|
2022-01-16 14:17:28 +03:00
|
|
|
set -l best_match (navi --print --best-match --query "$current_process")
|
2021-12-16 21:45:57 +03:00
|
|
|
|
2022-01-16 14:17:28 +03:00
|
|
|
if not test "$best_match" >/dev/null
|
2022-01-16 14:06:57 +03:00
|
|
|
return
|
|
|
|
end
|
2021-12-16 21:45:57 +03:00
|
|
|
|
2022-01-16 14:17:28 +03:00
|
|
|
if test -z "$best_match"
|
2022-01-17 02:54:29 +03:00
|
|
|
commandline -p (navi --print --query "$current_process")
|
2022-01-16 14:17:28 +03:00
|
|
|
else if test "$current_process" != "$best_match"
|
2022-01-16 14:06:57 +03:00
|
|
|
commandline -p $best_match
|
|
|
|
else
|
2022-01-17 02:54:29 +03:00
|
|
|
commandline -p (navi --print --query "$current_process")
|
2022-01-16 14:06:57 +03:00
|
|
|
end
|
2021-12-16 20:43:52 +03:00
|
|
|
end
|
2022-01-16 14:02:36 +03:00
|
|
|
|
2022-01-16 14:06:57 +03:00
|
|
|
commandline -f repaint
|
2021-12-16 15:35:15 +03:00
|
|
|
end
|
2021-12-16 14:24:21 +03:00
|
|
|
|
2022-01-16 14:06:09 +03:00
|
|
|
if test $fish_key_bindings = fish_default_key_bindings
|
2022-01-16 14:06:57 +03:00
|
|
|
bind \cg _navi_smart_replace
|
2022-01-16 14:06:09 +03:00
|
|
|
else
|
2022-01-16 14:06:57 +03:00
|
|
|
bind -M insert \cg _navi_smart_replace
|
2022-01-16 14:06:09 +03:00
|
|
|
end
|