I use Tmux daily and have grown quite attached to it and I'm asked frequently for a breakdown of my Tmux usage on my Twitch Stream, so here's an overview of Tmux Begin Style.

First Why I Like Tmux:

  • Multiple Windows and Split Panes in a Single Terminal Emulator!
  • Scripting my setup for various tasks
  • If your Terminal Emulator crashes, or you accidentally exit, just reattach!
  • Remote Sessions!
  • And many more things

Making Your Tmux Life Easier

Before we get started, here's a couple things I like to add to remove some friction interacting with Tmux and building up a config.

Quick Config Access

alias tt="nvim ~/.config/tmux/.tmux.conf"

Starting and Attaching to Sessions

alias tn="tmux -u new"
alias ta="tmux -u attach"

# Or if we are using an alternate Tmux config location
alias tn="tmux -u -f ~/.config/tmux/.tmux.conf new"
alias ta="tmux -u -f ~/.config/tmux/.tmux.conf attach"

I ain't got time to type tmux new and tmux attach each time! And I want to pass more flags every time!

The -f lets you point to an alternate config, if you maybe like to keep your home directory clean.

The `-u` is for UTF. Here's the details straight from the man pages:

-u   Write UTF-8 output to the terminal even if the first environment variable of LC_ALL, LC_CTYPE, or LANG that is set does not contain "UTF-8" or "UTF8".

Basic Tmux Usage

If you actually search Tmux Cheatsheet on DuckDuckGo, you'll see a nice list of commands.

The only ones I think you need in the beginning are (all starting with the prefix key first)

c - Create new window

w - List windows

d - Detach from session

, - Rename current window

% - split horizontally

z - Toggle pane zoom

o - Next pane

; - Previous pane

My advice is just keep looking up the commands when you feel the need for a new one, and slowly memorize more. No reason to try and memorize all at once.

My Tmux Config

Now 5that we have some basics, lets breakdown my .tmux.conf

# I like my prefix to be the same as my Vim <leader> which is `\`
set -g prefix 'C-\'
bind 'C-\' send-prefix
unbind C-b

# Easier Reloading of Config
bind r source-file ~/.config/tmux/.tmux.conf \; display "Fresh Tmux Config!"

# Use vim keybindings in copy mode
setw -g mode-keys vi

# Move around Tmux splits with vim like syntax
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# A Nice Red For the Active Panel
set-option -g pane-border-style fg="#00BEBE"

# I typically don't like to see a Status Bar
set-option -g status off

Not too long! Let's see what's happening.

Unbind the Default and add a Custom Prefix

unbind C-b
bind 'C-' send-prefix
set -g prefix 'C-\'

I like my prefix to be the same as my Vim <leader> which is \. This way, I just have to hold CTRL to differentiate, between Tmux and Vim Commands. However, many people like different options, and I think it's good to experiment with what feels natural under your fingers.

Quick Command for resourcing Tmux config

bind r source-file ~/.config/tmux/.tmux.conf \; display "Fresh Tmux Config!"

Note: if you remove an option from your configuration, reloading will have no effect.  It will only pick up new config or updating changes. So still useful in some situations, and <prefix>r, is a lot nicer than tmux source-file ~./.tmux.conf. If a config change isn't picking up, it's best to just exit tmux and start fresh.

Allow copying in Tmux and pasting in Vim

setw -g mode-keys vi

One of the first things that I found annoying in Tmux, was copying and pasting from Tmux to Vim. These settings will vary on your operating system, editor, and clipboard setup. I would highly suggest figuring out smooth copying and pasting, in the beginning of your Tmux journey.

Allow moving between Panes with Vim-like Directions

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

We must make everything like Vim! While I typically actually just move through windows just rotating around with o, it's nice to have some more control.

Turn the Status Bar Off

set-option -g status off

This is all personal preference. I don't like having lots of status bars cluttering my screen, and I can't remember a time I've ever looked at it on purpose. So I just started hiding it. However if you do like the Tmux status bar, at least spice it up a little.

Quick Example:

set -g status-style "bg=red"
set -ag status-style "fg=blue"
With -a, and if the option expects a string or a style, value is appended to the existing setting.

If I am going to use a status bar, I like to be able to toggle it on and off and move it from top to bottom:

bind-key S { set-option status on }
bind-key s { set-option status off }
bind-key i { set-option status-position top }
bind-key u { set-option status-position bottom }

Check the STYLES and STATUS section if you want more info about what is available:

man tmux

Important aside: Tmux is British colour not color

Some Color for the Split Panes

set-option -g pane-border-style fg=#BE0029

I like to adjust the color of the split, to make it more obvious which side I'm one.

Writing our own Tmux Script

Here's an example of a simple script, that creates 3 windows and runs 3 different scripts, and then splits the last window into 4 parts.

Note: you will need to install asciiquarium and TMatrix


tmux new-session -s Fun -n Asciiquarium -d
tmux new-window -t Fun -d -n Weather
tmux new-window -t Fun -d -n Matrix

tmux send-keys -t Fun:Asciiquarium "asciiquarium" Enter
tmux send-keys -t Fun:Weather "curl wttr.in"      Enter
tmux send-keys -t Fun:Matrix "tmatrix"            Enter

tmux select-window -t Fun:Matrix
tmux split-window -h
tmux send-keys -t Fun:Matrix "tmatrix -c red" Enter
tmux split-window -v
tmux send-keys -t Fun:Matrix "tmatrix -c yellow" Enter
tmux split-window -h
tmux send-keys -t Fun:Matrix "tmatrix -c blue" Enter
tmux select-layout tiled

tmux select-window -t Fun:Asciiquarium
tmux -u attach -t Fun

If you want a breakdown of this, checkout my breakdown on my Youtube Channel.

And if you want more Tmux, have any corrections please reach out! Or If want to hang out live, come visit me on Twitch.