Multiple tabs with tmux / tmuxinator and iTerm2
Asked Answered
V

4

16

I would like to open all my useful stuff like here in iTerm2:

iTerm2 without tmux

Not like this:

iTerm2 with tmux

I'm using tmuxinator I've defined some tabs. I wonder if it's possible to get the former behaviour at all.

Vedanta answered 7/12, 2012 at 15:2 Comment(0)
S
14

I just tried with tmux 1.8. Not totally obvious, but it works.

Here's what you do:

  1. Open iTerm2 (latest, be sure to have at least tmux 1.8 installed).
  2. In iTerm2, run command tmux <your tmuxinator profile>. Then detach ^b d.
  3. In iTerm2, run command tmux -CC attach -t <your session>. You will see your tabs open in different windows.
  4. Open menu Shell->Tmux->Dashboard
  5. Select and hide all the windows.
  6. Select all the hidden windows, and click Open in Tabs.

I'd like to know how to avoid the part about hiding and opening in tabs.

Subsistent answered 2/11, 2013 at 22:53 Comment(2)
Thanks, reading the doc was not enough to make it work. Even now, it's weird as this opened a new window with the tabs. I was hopping for a much better integration.Biddy
I've switched to opening an extra tab for each newly opened window, then you can drag and drop the tmuxinator-iterm2 tabs. Easier.Subsistent
L
10

Just wanted to add some comments onto what justingordon mentioned (1).

This all works great. But I found how to streamline step 4-6 so it happens automatically.

Go to iTerm2's Preferences, under General, you will see a section titled tmux. There's an option that says When attaching, open unrecognized windows in. If you change the current selection from Windows to Tabs.

Two extra tips.

  1. If you want you could select the option Automatically hide the tmux client session after connection. This will minimize the iTerm2 window in which you typed

    tmux -CC attach

  2. I also enabled the option Focus follows mouse. You can find this option under Preferences then Pointer. It should be the first option on the bottom left.

Leslileslie answered 25/6, 2014 at 21:59 Comment(0)
B
8

To use tmuxinator with iterm2 panes, use the following configuration:

 attach: false

in combination with

on_project_exit:
  - tmux -CC attach -t way

It looks like an issue in the documentations as told here

This is an example that I normally use:

# ~/.tmuxinator/way.yml
name: way
root: ~/learn/ruby/ruby-way/
attach: false
on_project_exit:
  - tmux -CC attach -t way

# Runs before everything. Use it to start daemons etc.
on_project_start:
  - export EDITOR="emacsclient --server-file=way -c"
  - export VISUAL=$EDITOR
  - emacs --daemon=way --title=RUBY-WAY
  - $EDITOR &

windows:
  - console:
      - echo "A currar"
  - testing:
      - echo "A testear"

I hope that this helps.

Belittle answered 6/10, 2018 at 14:40 Comment(1)
I've had to come back to this several times over the past few years. iTerm needs to improve their documentation.Rovit
A
0

Add this to your tmuxinator config:

attach: false
post: tmux -CC attach

https://github.com/tmuxinator/tmuxinator/pull/293

Allude answered 23/7, 2017 at 3:21 Comment(1)
POST was deprecated in favor of project hooksWristwatch

© 2022 - 2024 — McMap. All rights reserved.