Currently, I have some scripts to open up a new tmux session and populate that session with new windows and panes. This works fine, but sometimes I just want a window or two for monitoring and don't really want to create a whole new session and switch over to it.
My questions is would it be possible to have a script that creates a new window on an existing session?
I have tried a script to create a new window targeting a specific session using something like this :
tmux new-window -t "${current_session}" "${new_window}"
This makes the screen flash on the target session but no window is added. I have tried using the following on the target session with no luck.
:refresh-client
Also tried using send-keys but this seems to send keycodes as plain text (captured with vim on target session):
^B:new-window
UPDATE: Using the first method, during the screen flash of the target session, I can see that the last tmux tab does change to the "${new_window}" label for a fraction of a micro second, but it looks to be in the place of a current tab.
tmux new-window …
the operand that is not an option-argument is a shell command. It's"${new_window}"
in your case. What is${new_window}
then? If it's not a valid shell command then no wonder the new window exits immediately.