Developer Automation Tools Bootcamp

Learning about development tools and automation

View project onGitHub

Introduction to tmux


Here is a short divergence from server-side tools to one that helps your daily terminal experience. It is a terminal multiplexer called tmux.

What does a terminal multiplexer do? It allows your one terminal session to become many terminal sessions that look like this.
from https://tmux.github.io/

Powered by keyboard shortcuts

We're working in the terminal here. So everything will be activated by keyboard shortcuts.

Tmux does have one problem though. The default keyboard shortcuts SUCK. If you're familiar with screen, it used a ctrl-A based activation sequence. Tmux uses ctrl-b which is fine, but not what I was used to.

Further more, the keys to create new panes and adjust them were not intuitive. So for usability I followed the guide in the Pragmatic Programmers tmux - Productive Mouse Free Development.

Their example .tmux.conf file is available in the book's Source Code section.

The Common Shortcuts

Remember - these are the common shortcuts of a modified tmux configuration. But this configuration is loaded on to the classes VM, so I encourage you to be in tmux throughout the day's work.

Creating panes

  • ctrl-a + | (that is a pipe) splits the pane horizontally
  • ctrl-a + - splits the pane vertically
Moving between panes - think vi movements
  • ctrl-a + h Move the cursor to the pane to the right
  • ctrl-a + j Move the cursor to the pane above
  • ctrl-a + k Move the cursor to the pane below
  • ctrl-a + l Move the cursor to the pane to the left
Adjusting the size of panes
  • ctrl-a + H Make the pane larger to the right
  • ctrl-a + J Make the pane larger above
  • ctrl-a + K Make the pane larger down
  • ctrl-a + L Make the pane larger to the left
Swap a panes location
  • ctrl-a + } Moves the current content right
  • ctrl-a + { Moves the current content left

Further Reading

Workout

We are going to complete the following actions

  1. tmux is already installed on our Deployments VM. So vagrant up in the deployments folder of this project's Git repo.
  2. Start up tmux. You won't notice much difference at first.
  3. Make the panes in the tmux session look like the picture above. Two panes on the left half, two panes on the right half. The left half split "unevenly".
  4. That's it!