Coder Social home page Coder Social logo

tmuxinator's Introduction

Tmuxinator

Gem Version Build Status Coverage Status Code Climate Dependency Status Gitter

Create and manage tmux sessions easily.

Screenshot

Installation

gem install tmuxinator

Editor and Shell

tmuxinator uses your shell's default editor for opening files. If you're not sure what that is type:

echo $EDITOR

For me that produces "vim". If you want to change your default editor simply put a line in ~/.bashrc that changes it. Mine looks like this:

export EDITOR='vim'

tmux

The recommended version of tmux to use is 1.8 or later, with the exception of 2.5, which is not supported (see issue 536 for details). Your mileage may vary for earlier versions. Refer to the FAQ for any odd behaviour.

base-index

If you use a base-index other than the default, please be sure to also set the pane-base-index

set-window-option -g pane-base-index 1

Completion

Download the appropriate completion file from the repo and source the file. The following are example where the completion file has been downloaded into ~/.bin.

bash

Add the following to your ~/.bashrc:

source ~/.bin/tmuxinator.bash

zsh

Add the following to your ~/.zshrc:

source ~/.bin/tmuxinator.zsh

fish

Move tmuxinator.fish to your completions folder:

cp ~/.bin/tmuxinator.fish ~/.config/fish/completions/

Usage

A working knowledge of tmux is assumed. You should understand what windows and panes are in tmux. If not please consult the man pages for tmux.

Create a project

Create or edit your projects with:

tmuxinator new [project]

For editing you can also use tmuxinator open [project]. new is aliased to o,open, e, edit and n. Please note that dots can't be used in project names as tmux uses them internally to delimit between windows and panes. Your default editor ($EDITOR) is used to open the file. If this is a new project you will see this default config:

# ~/.tmuxinator/sample.yml

name: sample
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

windows:
  - editor:
      layout: main-vertical
      panes:
        - vim
        - guard
  - server: bundle exec rails s
  - logs: tail -f log/development.log

Windows

The windows option allows the specification of any number of tmux windows. Each window is denoted by a YAML array entry, followed by a name and command to be run.

windows:
  - editor: vim

Window specific root

An optional root option can be specified per window:

name: test
root: ~/projects/company

windows:
  - small_project:
      root: ~/projects/company/small_project
      panes:
        - start this
        - start that

This takes precedence over the main root option.

Panes

Note that if you wish to use panes, make sure that you do not have . in your project name. tmux uses . to delimit between window and pane indices, and tmuxinator uses the project name in combination with these indices to target the correct pane or window.

Panes are optional and are children of window entries, but unlike windows, they do not need a name. In the following example, the editor window has 2 panes, one running vim, the other guard.

windows:
  - editor:
      layout: main-vertical
      panes:
        - vim
        - guard

The layout setting gets handed down to tmux directly, so you can choose from one of the five standard layouts or specify your own.

Interpreter Managers & Environment Variables

To use tmuxinator with rbenv, RVM, NVM etc, use the pre_window option.

pre_window: rbenv shell 2.0.0-p247

These command(s) will run before any subsequent commands in all panes and windows.

Custom attachment and post commands

You can set tmuxinator to skip auto-attaching to the session by using the attach option.

attach: false

You can also run arbitrary commands by using the post option. This is useful if you want to attach to tmux in a non-standard way (e.g. for a program that makes use of tmux control mode like iTerm2).

post: tmux -CC attach

Passing directly to send-keys

tmuxinator passes commands directly to send keys. This differs from simply chaining commands together using && or ;, in that tmux will directly send the commands to a shell as if you typed them in. This allows commands to be executed on a remote server over SSH for example.

To support this both the window and pane options can take an array as an argument:

name: sample
root: ~/

windows:
  - stats:
    - ssh [email protected]
    - tail -f /var/log/stats.log
  - logs:
      layout: main-vertical
      panes:
        - logs:
          - ssh [email protected]
          - cd /var/logs
          - tail -f development.log

ERB

Project files support ERB for reusability across environments. Eg:

root: <%= ENV["MY_CUSTOM_DIR"] %>

You can also pass arguments to your projects, and access them with ERB. Simple arguments are available in an array named @args.

Eg:

$ tmuxinator start project foo
# ~/.tmuxinator/project.yml

name: project
root: ~/<%= @args[0] %>

...

You can also pass key-value pairs using the format key=value. These will be available in a hash named @settings.

Eg:

$ tmuxinator start project workspace=~/workspace/todo
# ~/.tmuxinator/project.yml

name: project
root: ~/<%= @settings["workspace"] %>

...

Starting a session

This will fire up tmux with all the tabs and panes you configured, start is aliased to s.

tmuxinator start [project] -n [name]

If you use the optional [name] argument, it will start a new tmux session with the custom name provided. This is to enable reuse of a project without tmux session name collision.

If there is a ./.tmuxinator.yml file in the current working directory but not a named project file in ~/.tmuxinator, tmuxinator will use the local file. This is primarily intended to be used for sharing tmux configurations in complex development environments.

Shorthand

The shell completion files also include a shorthand alias for tmuxinator that can be used in place of the full name.

mux [command]

Other Commands

Copy an existing project. Aliased to c and cp

tmuxinator copy [existing] [new]

List all the projects you have configured. Aliased to l and ls

tmuxinator list

Remove a project. Aliased to rm

tmuxinator delete [project]

Remove all tmuxinator configs, aliases and scripts. Aliased to i

tmuxinator implode

Examines your environment and identifies problems with your configuration

tmuxinator doctor

Shows tmuxinator's help. Aliased to h

tmuxinator help

Shows the shell commands that get executed for a project

tmuxinator debug [project]

Shows tmuxinator's version.

tmuxinator version

Project Configuration Location

Using environment variables, it's possible to house project configuration files in non-standard directories. (See PR #511.)

Tmuxinator will attempt to use the following environment variables (in this order) when creating or searching for existing project configuration files:

  • $TMUXINATOR_CONFIG
  • $XDG_CONFIG_HOME/tmuxinator
  • ~/.tmuxinator

This behavior is opt-in. If you do nothing, Tmuxinator will continue to use ~/.tmuxinator when searching for existing project configuration files or creating new project configuration files.

FAQ

Window names are not displaying properly?

Add export DISABLE_AUTO_TITLE=true to your .zshrc or .bashrc

Contributing

To contribute, please read the contributing guide.

Copyright

Copyright (c) 2010-2017 Allen Bargi, Christopher Chow. See LICENSE for further details.

tmuxinator's People

Contributors

adamstrickland avatar aziz avatar christophersjchow avatar dannluciano avatar doitian avatar drapergeek avatar endorama avatar ethagnawl avatar geggo98 avatar haletom avatar hedgehog avatar j3rn avatar jackturnbull avatar jneen avatar jpablobr avatar kerams avatar latortuga avatar marcosinger avatar nathankot avatar pczarn avatar podung avatar rglassett avatar richard-walton avatar rominf avatar rpassis avatar sachin21 avatar seanmalloy avatar spiegela avatar thedeeno avatar tsfoster avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.