tmuxinator を使ってみた

Jul 3, 2016  

tmuxinator

sudo gem install tmuxinator

環境変数 EDITOR SHELL と tmux のインストールが事前に必要

tmuxinator new tmux-window1

$HOME/.tmuxinator/ 以下にテンプレートファイルが作られる

# ~/.tmuxinator/tmux-window1.yml

name: tmux-window1
root: ~/

# Optional tmux socket
# socket_name: foo

# Runs before everything. Use it to start daemons etc.
# pre: sudo /etc/rc.d/mysqld start

# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions.
# pre_window: rbenv shell 2.0.0-p247

# Pass command line options to tmux. Useful for specifying a different tmux.conf.
# tmux_options: -f ~/.tmux.mac.conf

# Change the command to call tmux.  This can be used by derivatives/wrappers like byobu.
# tmux_command: byobu

# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used.
# startup_window: logs

# Controls whether the tmux session should be attached to automatically. Defaults to true.
# attach: false

# Runs after everything. Use it to attach to tmux with custom options etc.
# post: tmux -CC attach -t tmux-window1

windows:
  - editor:
      layout: main-vertical
      panes:
        - vim
        - guard
  - server: bundle exec rails s
  - logs: tail -f log/development.log
# ~/.tmuxinator/tmux-window1.yml

name: tmux-window1
root: ~/
windows:
  - server:
    - ls <%= @args[0] %>
  - editor:
      layout: main-vertical
      panes:
        - ls
        - ls
  - logs: ls

レイアウトは、名前に main が付いているものはひとつだけ大きいペインになるようだった。 even が付いているものは均等になるようだった。 tiled はタイル状に配置された。 ssh や sudo でパスワード認証を利用している時の良い方法は思いつかなかった。

name: tmux-window1
root: ~/
windows:
  - main:
      layout: tiled
      panes:
        - ls1:
          - echo 1
        - ls2:
          - echo 2
        - ls3:
          - echo 3
        - ls4:
          - echo 4
#   - server:
#     - ssh hogehoge
#     - <%= @settings["password"] %>