I have a script I want to run where I would start up two programs running inside of separate tmux sessions. The script I have now is pretty much:
!/bin/bash
tmux new -s test1 'mono --debug program1.exe'
tmux new -s test2 'python program2.py'
The problem I am having is the 2 programs are running in debug mode so they are actively outputting information to the tmux session. I'm not able to gain control to type anything into the tmux session after starting the program. I can however manually detach the session using the Ctrl + b d method. I'm not sure how to go about doing that in a bash script though.
I found the tmux detach command but since I am not sure how to type into the session after the program has started and debug information is being output I have no way of entering that command.
I also found one post that was saying there is a -d flag you can use for tmux that will start a session detached and I was hoping I could do something like tmux new -d test1 'mono --debug program1.exe' but that didn't seem to work. It seemed to complain about syntax in the -d flag.
You simply need to add the -d flag to each new command, in addition to its other options.
#!/bin/bash
tmux new -d -s test1 'mono --debug program1.exe'
tmux new -d -s test2 'python program2.py'
Note that you now have two sessions, either one of which you could attach to with tmux attach -s test1 or tmux attach -s test2. It might be simpler to run each command in a separate window of the same session:
tmux new -d -s test1 'mono --debug program1.exe'
tmux new-window 'python program2.py'
tmux attach -t test1
Replace new-window with split-window to run the commands in separate panes in the same window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With