navi/shell/navi.plugin.fish

34 lines
743 B
Fish
Raw Normal View History

2020-03-04 21:01:23 +00:00
#!/usr/bin/env fish
function __call_navi
2020-03-07 21:03:51 +00:00
navi --print
2020-03-04 21:01:23 +00:00
end
function navi-widget -d "Show cheat sheets"
begin
set ttysettings (stty -g)
2020-03-04 21:01:23 +00:00
stty sane
__call_navi | perl -pe 'chomp if eof' | read -lz result
and commandline -- $result
stty $ttysettings
2020-03-04 21:01:23 +00:00
end
commandline -f repaint
end
2021-12-16 11:24:21 +00:00
function smart_replace
#cli_buffer = commandline -
# split at last | left/right str
# set $user_input
# if query = answer : call Navi-widget
# else smart_replace :
# set output (navi --print --best-match --query $user_input)
# replace userinput string in clibuff or left string += output
# commandline append repaint
2020-03-04 21:01:23 +00:00
bind \cg navi-widget
if bind -M insert > /dev/null 2>&1
bind -M insert \cg navi-widget
2020-03-04 21:01:23 +00:00
end