From cfea884cf2e80eeb0934e3b354e272d3b24093ac Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 18 Oct 2022 20:02:16 +0200 Subject: [PATCH] rc windowing tmux: always spawn tmux-terminal-window in calling client The tmux-terminal-window command always spawns windows in the tmux session where the Kakoune session was started - even if the calling Kakoune client lives in a different tmux session. Fix this by always creating the window in the tmux session of the calling client. We already do the same for tmux-terminal-{horizontal,vertical}. I call tmux-terminal-impl with "new-window -a" (instead of "new-window"), so make sure the fix works for my use case. I considered retrieving the tmux session ID from the $TMUX environment variable but the tmux manpage only specifies that $TMUX contains "some internal data". --- rc/windowing/tmux.kak | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rc/windowing/tmux.kak b/rc/windowing/tmux.kak index f5a8fda3..a433692c 100644 --- a/rc/windowing/tmux.kak +++ b/rc/windowing/tmux.kak @@ -18,6 +18,9 @@ define-command -hidden -params 2.. tmux-terminal-impl %{ tmux_args="$1" if [ "${1%%-*}" = split ]; then tmux_args="$tmux_args -t ${kak_client_env_TMUX_PANE}" + elif [ "${1%% *}" = new-window ]; then + session_id=$(tmux display-message -p -t ${kak_client_env_TMUX_PANE} '#{session_id}') + tmux_args="$tmux_args -t $session_id" fi shift # ideally we should escape single ';' to stop tmux from interpreting it as a new command