Auto-Starting Tmux in iTerm2

This blog post is more than 1 year old and could be out of date!

I have been using Tmux a lot lately and was getting tired of having to attach to it everytime I start iTerm2. There had to be a way for me to initialize a Tmux session every time I start a new session of iTerm2. Luckily, it allows you to pass some text on startup! Using this feature (See below image for where...), I now pass up the below code to iTerm2:

tmux attach -t init || tmux new -s init

This snippet tries to attach to a Tmux instance called init and if it cannot it attach it creates one for me.

iTerm Tmux Setup


{
  metaData: {
    author: Josh Finnie
    tags: [
       OS X,
       iTerm2,
       tmux,
    ],
    postDate: 2014-05-16
  }
}