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