My TMUX Conf File Setup

Yash Ranadive
3 min readApr 12, 2016

--

Today, instead of doing a #TIL post I’m going to do a post on my TMUX setup. This post will cover some of the settings in my ~/.tmux.conf file.

What is Tmux?
In case you are wondering what TMUX is, it is a terminal multiplexer. GUI operating systems such as Mac OSX have windows that allow you to have several programs open at a time. Tmux is similar to that. It allows you to have multiple command line sessions open at a time. When running on a server, your session continues to run even if you get disconnected.

Terminology
Tmux windows can contain one or more panes. Each window has an index which identifies it. The index is shown next to the window name in the status bar at the bottom.

Here we have 3 windows. The current window is #3 (marked with the *) and it has 2 panes.

Prefix
I’ve mapped my prefix to Ctrl+a. The “prefix” allows you to activate Tmux and send commands to it.

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

Moving cursor to start
When you’re on the console, hitting Ctrl a twice will bring you to the start of the command.

#allow cursor to be moved to the front
unbind-key C-b
bind-key C-a send-prefix

Reload Conf File
Reload config file with Prefix + r

# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf

Force Renumbering of windows
When you close a window, Tmux retains the window numbers by default. To force renumbering of the windows use the following config:

# renumber windows when closing window in the middle
set-option -g renumber-windows on

Moving Around Panes
Being a Vim user I prefer navigating using the hjkl keys.

# move around panes with hjkl, as one would in vim after pressing ctrl-w
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

Pane Resizing
I use this quite a bit. It is handy when I connect my monitor to the laptop and want to resize the panes to fit the new monitor better.

# resize the pane using Prefix J and Prefix K
bind J resize-pane -D 15
bind K resize-pane -U 15

Window Auto Renaming
You can specify a custom name for a window by hitting Ctrl a , Tmux automatically renames a window based on the pane which has focus. If you want to retain the original name, you should use this setting:

# Turn auto-renaming of windows off
set-option -g allow-rename off

Pane Numbers
By default window and pane numbering starts at 0. Annoying right? This fixes it:

# Index numbering should start at 1
set -g base-index 1
# Base Index should start from 1 instead of 0
set-window-option -g pane-base-index 1
setw -g pane-base-index 1
set -g pane-base-index 1
set-option -g pane-base-index 1

Other Misc
Below section contains miscellaneous settings such as select a pane using the mouse, etc.

set -g status-keys vi
set -g history-limit 10000
setw -g mode-keys vi
setw -g mode-mouse on
setw -g monitor-activity on
setw -g mouse-select-window on
setw -g mouse-select-pane on

Plugin Management
I don’t use nearly as many plugins in tmux as I do in Vim. I really like the solarized plugin.

# Plugin Management using TPM
# Supports `github_username/repo` or full git repo URLs
set -g @tpm_plugins ‘ \
tmux-plugins/tpm \
seebi/tmux-colors-solarized \
# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell ‘~/.tmux/plugins/tpm/tpm’

Tmux Reference
Tmux is a powerful tool with many features. I use only a small subset of the features. Like any command line tool, you will have to remember a whole bunch of keystrokes to make things happen in Tmux. You can find the list of my frequently used Tmux commands here.

--

--

Yash Ranadive

Engineering @Facebook. Founder @GrepPage. Data Eng. @Lookout. Web, Search, 3D. Dog Parent. https://evidanary.github.io