summaryrefslogtreecommitdiff
path: root/shell/key-bindings.fish
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-04-22 00:30:09 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-04-22 00:32:18 +0900
commit318edc8c352250be04a9c2d15f5854084671c3df (patch)
tree4c8af289b93b2ffb7d22dc378d185995164180d0 /shell/key-bindings.fish
parent651a8f8cc20853341e4649e8246d3195c713961d (diff)
downloadfzf-318edc8c352250be04a9c2d15f5854084671c3df.tar.gz
Apply fzf-tmux to key bindings (#203)
Note that CTRL-T on bash is still using the old trick of send-keys.
Diffstat (limited to 'shell/key-bindings.fish')
-rw-r--r--shell/key-bindings.fish31
1 files changed, 7 insertions, 24 deletions
diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish
index f5f79c45..2caaf203 100644
--- a/shell/key-bindings.fish
+++ b/shell/key-bindings.fish
@@ -26,25 +26,14 @@ function fzf_key_bindings
end
function __fzf_ctrl_t
- if [ -n "$TMUX_PANE" -a "$FZF_TMUX" != "0" ]
- # FIXME need to handle directory with double-quotes
- tmux split-window (__fzf_tmux_height) "cd \"$PWD\";fish -c 'fzf_key_bindings; __fzf_ctrl_t_tmux \\$TMUX_PANE'"
- else
- __fzf_list | fzf -m > $TMPDIR/fzf.result
- and commandline -i (cat $TMPDIR/fzf.result | __fzf_escape)
- commandline -f repaint
- rm -f $TMPDIR/fzf.result
- end
- end
-
- function __fzf_ctrl_t_tmux
- __fzf_list | fzf -m > $TMPDIR/fzf.result
- and tmux send-keys -t $argv[1] (cat $TMPDIR/fzf.result | __fzf_escape)
+ __fzf_list | fzf-tmux (__fzf_tmux_height) -m > $TMPDIR/fzf.result
+ and commandline -i (cat $TMPDIR/fzf.result | __fzf_escape)
+ commandline -f repaint
rm -f $TMPDIR/fzf.result
end
function __fzf_ctrl_r
- history | fzf +s +m --tiebreak=index --toggle-sort=ctrl-r > $TMPDIR/fzf.result
+ history | fzf-tmux (__fzf_tmux_height) +s +m --tiebreak=index --toggle-sort=ctrl-r > $TMPDIR/fzf.result
and commandline (cat $TMPDIR/fzf.result)
commandline -f repaint
rm -f $TMPDIR/fzf.result
@@ -52,7 +41,7 @@ function fzf_key_bindings
function __fzf_alt_c
# Fish hangs if the command before pipe redirects (2> /dev/null)
- __fzf_list_dir | fzf +m > $TMPDIR/fzf.result
+ __fzf_list_dir | fzf-tmux (__fzf_tmux_height) +m > $TMPDIR/fzf.result
[ (cat $TMPDIR/fzf.result | wc -l) -gt 0 ]
and cd (cat $TMPDIR/fzf.result)
commandline -f repaint
@@ -61,16 +50,10 @@ function fzf_key_bindings
function __fzf_tmux_height
if set -q FZF_TMUX_HEIGHT
- set height $FZF_TMUX_HEIGHT
- else
- set height 40%
- end
- if echo $height | \grep -q -E '%$'
- echo "-p "(echo $height | sed 's/%$//')
+ echo "-d$FZF_TMUX_HEIGHT"
else
- echo "-l $height"
+ echo "-d40%"
end
- set -e height
end
bind \ct '__fzf_ctrl_t'