Getting the current session name from tmux
Are you talking to me?
Had the little mystery of how to get the name of the current session in tmux into a shell script. Why? Because that script should talk to the same pane/window/session again later. Hacking and searching around a bit, this is what I came up with:
SESSION=`tmux list-panes -F '#{session_name}'`
Funny enough it uses the list-panes command, which by default lists only the panes of the current window and session. Then, using the -F format string, we can tell it to give us the session name only.
Later I can use this in the script like this:
tmux select-window -t$SESSION:window_name
... and there shouldn't be any mistakes as to which session I'm talking to.
