Tmux is a terminal multiplexer

When I started in web development, Gnome terminal and its tab interface were the tools I used for my terminal needs. We can say that web development and the terminal go hand in hand. As I progressed with web development I started using Guake, a top-down terminal that gives me a quick access to a terminal while pressing just one key. Sadly though, tab interfaces on terminal windows pale in comparison to its modern browser counterparts. Ugly! Also, although I have naturally grasped the keyboard shortcuts for adding, removing and switching tabs, it still felt like it has held me back since most of the time I would just need to view the debug output of some process (i.e. Django development server). The time consumed switching between the open tabs is not acceptable.

So as I scoured the web for a solution and I encountered the term “terminal multiplexer”, which can be thought of as a graphical window manager for terminal sessions. So yeah, the next thing that came up was screen, which I was kind of familiar with, as I have used it maintain my session on remote servers. But it was the first time that I really found out you can maintain multiple windows (or tabs) within a screen session and you can also split a window into multiple panes. But there was one specific feature lacking on screen at the time: vertical splitting. Enter tmux. Other than the vertical splitting (which is now available in screen btw), tmux is easier to use for multi-user and multi-sessions, which makes it an even better fit for remote pair programming.

My ~/.tmux.conf.

Session Management

  • tmux new -s session_name creates a new tmux session named session_name tmux
  • attach -t session_name attaches to an existing tmux session named session_name
  • tmux switch -t session_name switches to an existing session named session_name
  • tmux list-sessions lists existing tmux sessions
  • tmux detach (prefix + d) detach the currently attached session

Windows

  • tmux new-window (prefix + c) create a new window
  • tmux select-window -t :0-9 (prefix + 0-9) move to the window based on index
  • tmux rename-window (prefix + ,) rename the current window
  • Shift+left, Shift+right switching when using my settings

Panes

  • tmux split-window (prefix + ", prefix + v) split the window into two vertical panes
  • tmux split-window -h (prefix + %, prefix + h) split the window into two horizontal panes
  • tmux swap-pane -[UDLR] (prefix + { or }) swap pane with another in the specified direction
  • tmux select-pane -[UDLR] (CTRL + arrow keys when using my settings) select the next pane in the specified direction