<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=338168267432629&amp;ev=PageView&amp;noscript=1">

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 …


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.

# remap prefix to Control + a
unbind C-b
set-option -g prefix C-a

#Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on

# Assign new shortcut keys for spliting window vertically and horizontally
bind-key v split-window -h
bind-key s split-window -v

# Navigate CTRL-arrow keys to switch panes
bind -n C-Left select-pane -L
bind -n C-Right select-pane -R
bind -n C-Up select-pane -U
bind -n C-Down select-pane -D

#Shift+arow keys to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf

# quick pane cycling
unbind ^A
bind ^A select-pane -t :.+

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

Similar posts

Get notified about the latest in Tech

Be the first to know about new tech from the experts at Bixly!