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".
This commit is contained in:
Johannes Altmanninger 2022-10-18 20:02:16 +02:00
parent 37dcba9089
commit cfea884cf2

View File

@ -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