Home

Awesome

Introduction

iTermocil allows you to setup pre-configured layouts of windows and panes in iTerm2, having each open in a specified directory and execute specified commands. You do this by writing YAML files to save your layouts. If you're using session restoration or saved window layouts in iTerm, you should find iTermocil is a nice upgrade on that.

iTermocil supports iTerm 2.x and the new 3.x (including later betas). It works better with the new 3.x versions which have improved Applescript support.

Example

Installing iTermocil

# Install `itermocil` via Homebrew
$ brew update
$ brew install TomAnthony/brews/itermocil

# Create your layout directory
$ mkdir ~/.itermocil

# Edit ~/.itermocil/sample.yml (look for sample layouts in this very `README.md`)
# There are also a variety of example files in 'test_layouts' directory in this repo
$ itermocil --edit sample

# Run your newly-created sample layout
$ itermocil sample

# Note that you can also used ~/.teamocil as your directory, if you're a teamocil user.

Using iTermocil

$ itermocil [options] <layout-name>

Alternatively, if you have an iTermocil.yml file in the current directory you can simply run itermocil and it will use that file, so you can have files inside your projects and sync via Github etc:

$ cd my_project
$ itermocil

iTermocil is compatible with all of teamocil's flags, and they all work in the same way.

Global options

OptionDescription
--listLists all available layouts in ~/.itermocil

Layout options

OptionDescription
--layoutTakes a custom file path to a YAML layout file instead of [layout-name]
--hereUses the current window as the layout’s first window
--editEdit the layout file in either $EDITOR or your preferred GUI editor
--showShows the layout content instead of executing it

Configuration

Session

KeyDescription
nameThis is currently ignored in iTermocil as there is no tmux session.
windowsAn Array of windows
preCommand that get executes before all other actions.

Windows

KeyDescription
nameAll iTerm panes in this window will be given this name.
rootThe path where all panes in the window will be started
layoutThe layout format that iTermocil will use (see below)
panesAn Array of panes
commandA command to run in the current window. Ignored if panes is present
commandsAn array of commands for run in the current window. Ignored if either panes or command is present
focusThis is currently unsupported in iTermocil

Panes

A pane can either be a String or a Hash. If it’s a String, Teamocil will treat it as a single-command pane.

KeyDescription
commandsAn Array of commands that will be ran when the pane is created
focusIf set to true, the pane will be selected after the layout has been executed

Examples

See some example of various layouts below, or see Layouts for more information on the available layouts. There is also a variety of example layout files in this repo.

Simple two pane window

windows:
  - name: sample-two-panes
    root: ~/Code/sample/www
    layout: even-horizontal
    panes:
      - git status
      - rails server
.------------------.------------------.
| (0)              | (1)              |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
'------------------'------------------'

Simple three pane window

windows:
  - name: sample-three-panes
    root: ~/Code/sample/www
    layout: main-vertical
    panes:
      - vim
      - commands:
        - git pull
        - git status
        name: 'git'
      - rails server

Note: the 'name' directive in 'commands' in an iTermocil specific addition, which will cause teamocil to fail if it tries to parse the file.

.------------------.------------------.
| (0)              | (1)              |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |------------------|
|                  | (2)              |
|                  |                  |
|                  |                  |
|                  |                  |
'------------------'------------------'

Simple three pane window (flipped)

windows:
  - name: sample-three-panes
    root: ~/Code/sample/www
    layout: main-vertical-flipped
    panes:
      - commands:
        - git pull
        - git status
      - rails server
      - vim
.------------------.------------------.
| (0)              | (2)              |
|                  |                  |
|                  |                  |
|                  |                  |
|------------------|                  |
| (1)              |                  |
|                  |                  |
|                  |                  |
|                  |                  |
'------------------'------------------'

Simple four pane window

windows:
  - name: sample-four-panes
    root: ~/Code/sample/www
    layout: tiled
    panes:
      - vim
      - foreman start web
      - git status
      - foreman start worker
.------------------.------------------.
| (0)              | (1)              |
|                  |                  |
|                  |                  |
|                  |                  |
|------------------|------------------|
| (2)              | (3)              |
|                  |                  |
|                  |                  |
|                  |                  |
'------------------'------------------'

Two pane window with focus in second pane

windows:
  - name: sample-two-panes
    root: ~/Code/sample/www
    layout: even-horizontal
    panes:
      - rails server
      - commands:
          - rails console
        focus: true
.------------------.------------------.
| (0)              | (1) <focus here> |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
'------------------'------------------'

A pane-less window

windows:
  - name: pane-less
    root: ~/Code/sample/www
    command: rails console
  - name: one_more-pane-less
    root: ~/Code/sample/www
    commands:
      - bundle update
      - rails server

Additional Layouts

In the Layouts file you can see these additional layouts:

teamocil

iTermocil was originally inspired by and is compatible with teamocil, allowing anyone with teamocil files to execute those files natively in iTerm2, without needing tmux or any other dependency. However, iTermocil also has support for additional directives which will cause teamocil to fail, if used.

Notes

Teamocil allows supplying a name for a tmux session which has no purpose in iTerm, and so that option is ignored.

In tmux it is 'windows' that have names, whereas in iTerm each pane in a window can have a name. iTermocil will name all the child panes of a window by the window name given in a termocil file.

iTermocil works for iTerm 2+, but the script support is better in iTerm 2.9 beta so things run a bit faster/cleaner with iTerm 2.9+. If using beta builds you should grab the latest nightly, as the 2.9.20150626 'recommended beta' build does not have the required script hooks for iTermocil to work (and I have no plans to kludge something just for an incomplete beta that will never be released).

Starting with version 1.0.0, iTermocil uses Python3. If you need iTermocil for Python2, please use 0.2.1.

Shell autocompletion

Zsh autocompletion

To get autocompletion when typing itermocil <Tab> in a zsh session, add this line to your ~/.zshrc file:

compctl -g '~/.itermocil/*(:t:r)' itermocil

Bash autocompletion

To get autocompletion when typing itermocil <Tab> in a bash session, add this line to your ~/.bashrc file:

complete -W "$(itermocil --list)" itermocil

fish autocompletion

To get autocompletion when typing itermocil <Tab> in a fish session, add this line to your ~/.config/fish/config.fish file:

complete -c itermocil -a "(itermocil --list)"

Contributors

I'd love any ideas/feedback/thoughts, please open an issue or create a fork and send a pull request, like these wonderful people:

A huge thanks to Rémi Prévost who authored teamocil, which inspired iTermocil. It is a fantastic tool, and I'm hoping that iTermocil helps more people discover teamocil.

To Do

License

iTermocil is © 2016 Tom Anthony and may be freely distributed under the MIT license. See the LICENSE file for more information.