Merge remote-tracking branch 'lenormf/fix-tmux-send-text'

This commit is contained in:
Maxime Coste 2016-06-25 00:06:02 +01:00
commit 014cd50883

View File

@ -3,11 +3,21 @@
hook global KakBegin .* %{ hook global KakBegin .* %{
%sh{ %sh{
VERSION_TMUX=$(tmux -V)
VERSION_TMUX=$(expr "${VERSION_TMUX}" : 'tmux \([0-9]*\).*')
if [ -n "$TMUX" ]; then if [ -n "$TMUX" ]; then
echo " if [ "${VERSION_TMUX}" -gt 1 ]; then
alias global repl tmux-repl-horizontal echo "
alias global send-text tmux-send-text alias global repl tmux-repl-horizontal
" alias global send-text _tmux-send-text
"
else
echo "
alias global repl _tmux-repl-disabled
alias global send-text _tmux-repl-disabled
"
fi
fi fi
} }
} }
@ -39,7 +49,7 @@ def tmux-repl-window -params 0..1 -command-completion -docstring "Create a new w
tmux-repl-impl 'new-window' %arg{@} tmux-repl-impl 'new-window' %arg{@}
} }
def tmux-send-text -docstring "Send selected text to the repl pane in tmux" %{ def -hidden _tmux-send-text -docstring "Send selected text to the repl pane in tmux" %{
nop %sh{ nop %sh{
tmux set-buffer -b kak_selection "${kak_selection}" tmux set-buffer -b kak_selection "${kak_selection}"
kak_orig_window=$(tmux display-message -p '#I') kak_orig_window=$(tmux display-message -p '#I')
@ -51,3 +61,8 @@ def tmux-send-text -docstring "Send selected text to the repl pane in tmux" %{
tmux select-pane -t:.${kak_orig_pane} tmux select-pane -t:.${kak_orig_pane}
} }
} }
def -hidden _tmux-repl-disabled %{ %sh{
VERSION_TMUX=$(tmux -V)
printf %s "echo -color Error %{The version of tmux is too old: got ${VERSION_TMUX}, expected >= 2.x}"
} }