I have a question similar to this guy https://stackoverflow.com/questions/5609192/how-to-set-up-tmux-so-that-it-starts-up-with-specified-windows-opened but more specific.

I want to do this in a single tmux.conf file, without any key-bindings to load specific sessions per @jasonwryan 's answer.

So, how do I do this? I set my tmux.conf:

new  -s mySession -n myWindow
neww -n foo/bar foo
splitw -v -p 50 -t 0 bar
selectw -t 1 
selectp -t 0

but it doesn't split the window when I start tmux.

Update: I don't think the attach is working. If I ditch the second 'foo' window and simplify my tmux.conf :

# set panes the way I want them
# if I started tmux by just running 'tmux' in command line, it automatically creates session(0) so...

new -s mySession -n myWindow    # ... create new session (1) with new window (0)
select-window -t myWindow       # select myWindow (0)
splitw -v -p 50 -t myWindow     # split myWindow (0) vertically into halves(50 percent)

attach -s mySession             # error usage: attach-session [-dr] [-t target-session]
attach-session -t mySession     # so this doesn't work either
switch -t mySession             # nor doesn't work

So what am I missing? If I manually switch sessions once tmux launches by doing CTRL+b s and then selecting the mySession, the panes are split and everything is great. So how do I attach to or switch to mySession from session(0)?

  • 3
    Start tmux with tmux a...
    – jasonwryan
    Mar 14, 2013 at 1:13
  • this worked once I made the changes in my Update, but I should be able to do the "attach" INSIDE the tmux.conf, right?
    – tir38
    Apr 3, 2013 at 21:44

2 Answers 2


After you've created the new session, create a new window, and split a window into 2 panes, you still need to attach to the session. Add

attach -s mySession

to the end of the commands you show above.


You have to tell tmux which session to start, but not in this configuration file, as others have suggested, but rather with the command you start tmux with.

Use the following command.

tmux -f <your tmux.conf file> attach -t mySession

I don't think it's possible to do it from inside the configuration file, since that applies to that current session, but if you start it with the simple tmux command, that creates an new session.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .