From f278212132370aa0ac40158021ce0a52bbbc05e8 Mon Sep 17 00:00:00 2001 From: Thomas Friedel Date: Fri, 11 Oct 2019 20:31:35 +0200 Subject: [PATCH] navi fish plugin with ability to edit commandline --- navi.plugin.fish | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/navi.plugin.fish b/navi.plugin.fish index ffae787..ce2ad8b 100644 --- a/navi.plugin.fish +++ b/navi.plugin.fish @@ -1,21 +1,17 @@ -function navi-widget -d 'Call navi' - set -q NAVI_USE_FZF_ALL_INPUTS; or set -l NAVI_USE_FZF_ALL_INPUTS "true" - begin - navi --print | while read -l r; set result $result $r; end - - if [ -n "$result" ] - echo $result - - # Remove last token from commandline. - commandline -t "" +function navi_key_bindings + function navi-widget -d "Show cheat sheet" + set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40% + begin + set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m" + stty sane + env NAVI_USE_FZF_ALL_INPUTS=true navi --print query (commandline) | perl -pe 'chomp if eof' | read -lz result + and commandline -- $result end + commandline -f repaint end - # commandline -f repaint -end - -bind \cg navi-widget - -if bind -M insert > /dev/null 2>&1 - bind -M insert \cg navi-widget + bind \cg navi-widget + if bind -M insert > /dev/null 2>&1 + bind -M insert \cg navi-widget + end end