Home Blog About Contact

Introduction to Tmux

Sat, Sep 03, 16

tmux is a “terminal multiplexer”, it enables a number of terminals (or windows) to be accessed and controlled from a single terminal. tmux is intended to be a simple, modern, BSD-licensed alternative to programs such as GNU screen.

Install tmux.

tmux depends on libevent 2.x. Download it from: libevent.org

From source

By default, tmux will use the utempter library to update utmp(5), if it is installed. Run configure with --disable-utempter to disable this.

To build tmux from a release tarball, do:

$ ./configure && make
$ sudo make install

To get and build the latest from version control:

$ git clone https://github.com/tmux/tmux.git
$ cd tmux
$ sh autogen.sh
$ ./configure && make

Install tmux in Mac OSX

Yes, you can do brew install tmux

Starting Tmux
You can start a tmux session by tmux attach or simply tmux a command.

Managing the configuration.

You can manage all the configurations with .tmux.conf file. Which will reside in your home folder. You can check with cat ~/.tmux.conf to see whether there is any.

Multiple Pane Synchronization

What setw synchronise-panes gives us is that it simultaneously sends keyboard input from one pane to the rest of the panes. (In this case, we can also see the the Elixir REPL is far superior because of the colored output.)

Obviously, this demonstration is a mere party trick to impress developers and nothing more. A good use case is having to perform a repetitive operation on multiple machines. For example, imagine having a tmux session connected to four remote hosts and having to executer the exact same command on all of them.

Noteworthy plugins.

1. Tmux Plugin Manager

Installs and loads TMUX plugins.

2. tmux-resurrect

Restore tmux environment after system restart.

Tmux is great, except when you have to restart the computer. You lose all the running programs, working directories, pane layouts etc. There are helpful management tools out there, but they require initial configuration and continuous updates as your workflow evolves or you start new projects.

3. tmux-sensible

A set of tmux options that should be acceptable to everyone.

This is how my own .tmux.conf file looks like, i shall explain what all are there. {% gist niksmac/76c1381482938d23e8ea2c39f4ef0511 %}

Some good reads

  1. thoughtbot.com
  2. quora.com
Full Version of Introduction to Tmux