Skip to content

Instantly share code, notes, and snippets.

@josellausas
Last active November 14, 2016 20:06
Show Gist options
  • Save josellausas/dbed36c268ecc295dddc9dd7cb832a20 to your computer and use it in GitHub Desktop.
Save josellausas/dbed36c268ecc295dddc9dd7cb832a20 to your computer and use it in GitHub Desktop.
Instructions for setting up a testing environment with Tmuxinator

Tmuxinator test environment

  1. Install things

Install tmux and tmuxinator (I used brew and gem install tmuxinator)

  1. Create a new tmuxinator project

Run in terminal: tmuxinator new [projectname] (replace [projectname] with a project name)

This should open the new configuration file on your editor.

Use tmuxinator open [projectname] to edit the config file.

  1. Configure tmuxinator session

This is my tmuxinator config:

You might want to replace the following options:

root: to your project's directory

panes: These are the commands that run in each windown pane at startup. Use these to get all the servers started and navigate to the correct directories.

# ~/.tmuxinator/mapstory.yml

name: projectname
root: ~/code/project01/projectname

# 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 mapstory

windows:
  - main:
      layout: tiled
      panes:
        - cd scripts/provision; vagrant reload && vagrant ssh
        - cd app/tests; ./startWebDriver.sh
        - cd app/tests; subl .;cowsay "Hello"
  1. Start your environment

Start the session with: tmuxinator start [yourprojectname]

  1. (Optional) Configure tmux

This is my tmux config file:

# Soruce: https://danielmiessler.com/study/tmux/#intro

# Sets Ctrl-b + r as a reload shortcut
bind r source-file ~/.tmux.conf

# Rename the terminal
set -g set-titles on

# set -g set-titles-string '#(whoami)::#h::#(curl ipecho.net/plain;echo)'
set -g set-titles-string '#(whoami) :: #h'

# Status bar config
# set -g status-utf8 on
set-option -g prefix C-a
set -g status-bg white
set -g status-fg black

# For mac mouse scrolling
set -g mouse on
bind-key -t vi-copy WheelUpPane scroll-up
bind-key -t vi-copy WheelDownPane scroll-down
set-option -g default-command "reattach-to-user-namespace -l bash"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment