18

When I run tmux new-window from a script outside of my current tmux session, how can I specify which session the new window should be associated with?

2 Answers 2

19

Though not very clearly documented, it turns out windows can be specified as session-name:window-number, so specifying tmux new-window -t SESSION: results in creating a new window in the session. The session name or default number may be used.

16

Just improving @David's answer, because it wan't very clear for me and I spent some time investigating this.

Suppose, we created a session and a window with this command:

tmux new-session -d -s my-session-1 -n my-window-1 'sleep 10000'

To add a new window into it:

tmux new-window -n my-window-2 -t my-session-1: 'sleep 10000'

(notice the colon after the session name)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.