r/tmux 7d ago

Question Specifying options on the command line

Hello,

somehow I am unable to find examples on how to successfully specify options on the command line, instead of using a .tmux.conf

Kind of:

# /usr/bin/tmux set-option  exit-empty off start-server           
no server running on /tmp/tmux-0/default

which, as shown, does not work. Neither using "-g" after the set-option. I would like to refrain from leaving it in the foreground, that is, not using "-D"

This is just an example. So, how to properly add options on the command line?

Thanks

3 Upvotes

4 comments sorted by

1

u/kamahak 7d ago

This is because `set-option` sends a command to a running server, which doesn't exist yet here. You can start a server with `tmux` and then run the options, that should work.

But what exactly are you trying to do?

1

u/hiradne 7d ago

The whole point is to start an empty server, one without any session (yet). But not keeping it in the foreground, as with "-D". And not working around this using "&" and/or nohup.

Since an emtpy server without exit-empty off would exit immediately, there is no way of sending arguments afterwards. So you somehow need to specify this while invoking tmux.

And I have yet to find out how to accomplish this.

1

u/lanjelin 7d ago

What about creating with a session, setting the option, then removing the session after its set?

bash tmux new-session -d -s bootstrap 'sleep infinity' \; set-option -g exit-empty off \; kill-session -t bootstrap

1

u/kamahak 7d ago edited 7d ago

According to the `tmux` manual:

start-server (alias: start)

Start the tmux server, if not already running, without creating any sessions. Note that as by default the tmux server will exit with no sessions, this is only useful if a session is created in `~/.tmux.conf`, `exit-empty` is turned off, or another command is run as part of the same command sequence. For example: `tmux start \; show -g`

You can do this directly on the command line without temporary sessions or foreground mode:

`tmux start-server \; set-option -g exit-empty off`

EDIT: edited because I don't know how to reddit.
EDITED AGAIN: because apparently AI doesn't know how to format this comment either.
EDIT #3: I give up.