From ef19d318c4b3e5b168e49c18fe156d90eb521c79 Mon Sep 17 00:00:00 2001 From: Tobias Frilling Date: Fri, 18 Jan 2019 14:42:04 +0100 Subject: [PATCH] Better tmux REPL support This allows one REPL per kakoune session and allows the REPL to run in a different tmux session than the kakoune client. --- rc/extra/tmux-repl.kak | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rc/extra/tmux-repl.kak b/rc/extra/tmux-repl.kak index a0873874..a176f5f5 100644 --- a/rc/extra/tmux-repl.kak +++ b/rc/extra/tmux-repl.kak @@ -1,6 +1,8 @@ # http://tmux.github.io/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ +declare-option -docstring "tmux pane id in which the REPL is running" str tmux_repl_id + hook global KakBegin .* %sh{ if [ -n "$TMUX" ]; then VERSION_TMUX=$(tmux -V | cut -d' ' -f2) @@ -31,8 +33,7 @@ define-command -hidden -params 1..2 tmux-repl-impl %{ shift tmux_cmd="$@" tmux $tmux_args $tmux_cmd - tmux set-buffer -b kak_repl_window $(tmux display-message -p '#I') - tmux set-buffer -b kak_repl_pane $(tmux display-message -p '#{pane_id}') + printf "set-option global tmux_repl_id '%s'" $(tmux display-message -p '#{session_id}:#{window_id}.#{pane_id}') } } @@ -56,13 +57,7 @@ define-command -hidden tmux-send-text -params 0..1 -docstring "tmux-send-text [t else tmux set-buffer -b kak_selection "$1" fi - kak_orig_window=$(tmux display-message -p '#I') - kak_orig_pane=$(tmux display-message -p '#P') - tmux select-window -t:$(tmux show-buffer -b kak_repl_window) - tmux select-pane -t:.$(tmux show-buffer -b kak_repl_pane) - tmux paste-buffer -b kak_selection - tmux select-window -t:${kak_orig_window} - tmux select-pane -t:.${kak_orig_pane} + tmux paste-buffer -b kak_selection -t "$kak_opt_tmux_repl_id" } }