Did I Improve ThisBlogAbout

Tmux - terminal multiplexer

04 July, 2020 - 2 min

Tmux is a terminal multiplexer. I use it to manage different terminal contexts. For example to have a window with vim for editing my website and another for the website local environment to be running.

Tmux panes Fig. 1 - Tmux panes example

On the image above we can see three tmux panes:

  • nvim, where I edit this website - left.
  • open entry to on my notes - top right.
  • git workflow - bottom right

We can also see on the bottom indicating that I have two tmux windows opened:

  • code - the set of three panes we see with vim, notes and git.
  • server - where I'm running the website's local server.

When I'm focused on editing the files I use tmux's <prefix>+z to zoom the vim pane, thus hiding the right panes and only displaying vim. Using <prefix>+z again will restore the normal view.

These are the configs I use on tmux. Check my full configuration here.

# unbinds the ctrl+b prefix and sets it to ctrl+a
unbind C-b 
set -g prefix C-a  

#bind C-a C-a to 'home', or start of line, which was C-a previously
bind C-a send-prefix

#reload tmux.conf
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"

#-------------------------------------------------------#
# Pane navigation non-standard because of resizing pane prefix-L
#-------------------------------------------------------#
bind -r b previous-window
bind -r n next-window
bind -r p last-window

#-------------------------------------------------------#
# Terminal admin:
#-------------------------------------------------------#
#set mouse off/on - if off, forces you to use keyboard with prefix-[
set -g mouse on

#-------------------------------------------------------#
# PANE NAVIGATION/MANAGEMENT
#-------------------------------------------------------#
# splitting panes
bind \\ split-window -h -c '#{pane_current_path}'
bind - split-window -v -c '#{pane_current_path}'

# open new panes in current path
bind c new-window -c '#{pane_current_path}'

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

#Resizing panes:
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r H resize-pane -L 2
bind -r L resize-pane -R 2

#-------------------------------------------------------#
# Setting escape time delay to be smaller 
# to make tmux more responsive to commands
#-------------------------------------------------------#
set -s escape-time 1


Thanks for reading!

Vicente




A list of articles in the series Terminal Workflow:

  1. Terminal Base Setup

2. Tmux - terminal multiplexer

  1. NeoVim - text editor
  2. Jrnl - note app
  3. Pass - password manager
  4. Ranger - file manager
  5. Simple Terminal Apps
  6. Terminal Aliases