I'm working on small script that is interactive. I'm trying to start tmux both specifying the command (so that when the process exits the tmux session exits) and using a configuration file - but it doesn't appear that this is possible.
tmux new-session -d -s myapp 'python myapp.py' -f 'myapp-tmux.conf'
Any ideas?
You need to move the -f …
to before new-session
. It is an argument for tmux itself; the new-session
(sub)command does not understand or accept -f
.
Also, the configuration file (~/.tmux.conf
, or the one specified with -f
) is only used when initially starting a server. If you have other (possibly detached) sessions running under the default server, then the -f …
portion of your command will go unused. Check for other sessions with tmux ls
.
You might want to use -L
(or -S
) to specify an alternate server (i.e. one where you can make sure your session is always the only one):
tmux -L myapp -f myapp-tmux.conf new-session -d -s myapp 'python myapp.py'
Later, to attach to that session:
tmux -L myapp attach -t myapp
(You may leave off -t myapp
if the sever only has that one session.)
If you do want to use you existing server (so that changes made via the configuration file can affect your other sessions), then you might want to use source
instead:
tmux source myapp-tmux.conf \; new-session -d -s myapp 'python myapp.py'
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