mirror of
https://github.com/denisidoro/navi
synced 2024-11-21 19:13:07 +00:00
Merge pull request #655 from DevAtDawn/master
Add “smart replace” functionality to the fish shell widget
This commit is contained in:
commit
91783f6764
1 changed files with 33 additions and 5 deletions
|
@ -1,5 +1,3 @@
|
||||||
#!/usr/bin/env fish
|
|
||||||
|
|
||||||
function __call_navi
|
function __call_navi
|
||||||
navi --print
|
navi --print
|
||||||
end
|
end
|
||||||
|
@ -16,7 +14,37 @@ function navi-widget -d "Show cheat sheets"
|
||||||
commandline -f repaint
|
commandline -f repaint
|
||||||
end
|
end
|
||||||
|
|
||||||
bind \cg navi-widget
|
# set -g navi_last_cmd ""
|
||||||
if bind -M insert > /dev/null 2>&1
|
|
||||||
bind -M insert \cg navi-widget
|
function smart_replace
|
||||||
|
set -l current_process (commandline -p)
|
||||||
|
|
||||||
|
if [ $current_process = "" ]
|
||||||
|
commandline -p (navi --print)
|
||||||
|
commandline -f repaint
|
||||||
|
else
|
||||||
|
set -l best_match (navi --print --best-match --query $current_process)
|
||||||
|
|
||||||
|
if not [ $best_match > /dev/null ];
|
||||||
|
commandline -p $current_process
|
||||||
|
commandline -f repaint
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if [ $best_match = "" ]
|
||||||
|
commandline -p (navi --print --query $current_process)
|
||||||
|
commandline -f repaint
|
||||||
|
else if [ $current_process != $best_match ]
|
||||||
|
commandline -p $best_match
|
||||||
|
commandline -f repaint
|
||||||
|
else if [ $current_process = $best_match ]
|
||||||
|
commandline -p (navi --print --query $current_process)
|
||||||
|
commandline -f repaint
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
bind \cg smart_replace
|
||||||
|
if bind -M insert > /dev/null 2>&1
|
||||||
|
bind -M insert \cg smart_replace
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue