navi/shell/navi.plugin.fish

27 lines
650 B
Fish
Raw Normal View History

2022-01-16 18:22:32 +08:00
function _navi_smart_replace
2022-01-16 18:37:46 +08:00
set -l current_process (commandline -p | string trim)
2021-12-16 10:43:52 -07:00
2022-01-16 19:02:36 +08:00
if test -z $current_process
commandline -i (navi --print)
2021-12-16 05:21:07 -07:00
else
2021-12-16 10:43:52 -07:00
set -l best_match (navi --print --best-match --query $current_process)
2022-01-16 18:22:32 +08:00
if not test $best_match > /dev/null
return
end
2022-01-16 18:22:32 +08:00
if test $best_match = ""
2022-01-16 19:02:36 +08:00
commandline -p (navi --print --query $current_process)
2022-01-16 18:22:32 +08:00
else if test $current_process != $best_match
2021-12-16 10:43:52 -07:00
commandline -p $best_match
2022-01-16 18:22:32 +08:00
else
2021-12-16 10:43:52 -07:00
commandline -p (navi --print --query $current_process)
end
2021-12-16 05:21:07 -07:00
end
2022-01-16 19:02:36 +08:00
commandline -f repaint
2021-12-16 05:35:15 -07:00
end
2021-12-16 04:24:21 -07:00
2022-01-16 18:25:16 +08:00
bind \cg _navi_smart_replace
bind -M insert \cg _navi_smart_replace