Let’s say that I start a kakoune session named “k1” in a tmux session named “t1”.
Then I open a new terminal with a new tmux session “t2”, and start a kakoune client connect to “k1” ( kak -c k1)
Now if I want to get the name of the current tmux session from my connected kakoune client ( running %sh{ tmux display-message -p '#S' } ) I don’t get “t2” but “t1” instead.
How can I get the tmux session in which the client is running, instead of the tmux session in which the kakoune session is running?
Since tmux communicates the active session using environment variables, you can re-export the client versions for the command (which runs on the server):
While you can get the session from the TMUX variable yourself, I would recommend leaving its contents as a “black box” for tmux to parse, since it is not documented. with the above trick, you can run any tmux command as though it were in the client, not just getting the session. ($TMUX_PANE is not required for the above command, but why not?)