Tmux Transformed How I Use My Terminal

The window manager of terminals that revolutionized my workflow.

Michael Bao
Unixification
Published in
4 min readNov 18, 2023

--

screenshot by author

I've lived in the terminal ever since I moved to Linux and eventually macOS. Whether it was programming projects or writing notes, the terminal was where I was. However, I never actually used tmux, rather preferring to resort to the use of window managers.

I will be honest, I was hesitant to add tmux to my toolbox because altering a workflow to become second nature would be a huge hassle. Yet recently, I brought myself to it. And it has completely changed my development workflow.

Before I started using tmux I didn’t see any reason even to touch it. I thought it would add another step to my workflow — an unnecessary step that any window manager could fulfill. I was, however, mistaken.

Now every time I open a new terminal window I have the option to land in numerous directories. Moreover, tmux's ability to have split panes and multiple windows is impeccable when needing to run a quick command or have several files open.

For those who don’t know, tmux is a terminal multiplexer. According to tmux’s GitHub, “you switch easily between several programs in one terminal, detach them (they keep running in the background), and reattach them to a different terminal.” If you are familiar with window managers, tmux is simply a window manager for terminals.

Setup

Other than the main config for tmux my current setup includes a tmux-sessionizer allowing me to save sessions in specific directories I want. This runs initially when I open the terminal making it trivial to land anywhere without traversing multiple directories.

For example, the following is what will show up initially.

tmux-sessionizer (screenshot by author)

Furthermore, due to it using fzf I can easily find what I need by stringing multiple words.

tmux-sessionizer (screenshot by author)

Config

There are several settings that I have changed to my preference. First, my basic preferences are mainly for ensuring that my Neovim theme works properly, changing the base index, and turning off any annoying bells.

set-option -sa terminal-overrides ',xterm*:Tc'
set -g base-index 1
setw -g pane-base-index 1
set-option -g renumber-windows on

setw -g monitor-activity off
set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
set -g bell-action none

Continuing in my config, I set my keybinds. After a few different prefix keybinds, I eventually ended up with ctrl+\, because it was quickly accessible and didn’t have any conflicts with Neovim. The other keybinds are personal preferences that I appreciate. ctrl+\ f is set to open my tmux-sessionizer for convenience in switching directories and projects.

bind r source-file ~/.config/tmux/tmux.conf

# changing panes
bind-key h select-pane -L
bind-key l select-pane -R
bind-key j select-pane -D
bind-key k select-pane -U

# selection
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel

# split panes
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"

bind-key -r f run-shell "tmux neww ~/.scripts/tmux-sessionizer"

Next are my plugins — simple and clean. I use the Tmux Plugin Manager to manage plugins, tmux-sensible for simple settings, and tmux-yank for comfortable copying.

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'

run '~/.config/tmux/plugins/tpm/tpm'

Finally, I have my theme — elegant and essential.

tmux screenshot (screenshot by author)
set-option -g pane-active-border-style "bg=default fg=magenta"
set-option -g pane-border-style "bg=default fg=black"

# ----- Messages -----

set-option -g mode-style 'bg=black, fg=magenta'
set-option -g message-style 'bg=color18, fg=magenta'

# ----- Center -----
set-option -g status-justify centre
set-option -g status-style "bg=color18"
set-window-option -g window-status-current-format '#[bold]#[fg=blue, bg=color18]#[fg=color18, bg=blue]#I:#W#[fg=blue, bg=color18]'
set-window-option -g window-status-format '#I:#W'
set-window-option -g window-status-separator ' '
set-window-option -g window-status-style "bg=color18"
set-window-option -g window-status-current-style "bg=blue,fg=color18"

# ----- Left -----
set-option -g status-left ' #S #[fg=blue, bg=color18] '
set-option -g status-left-style "bg=blue,fg=color18"
set-option -g status-left-length 30

# ----- Right -----
set-option -g status-right "#[fg=blue, bg=color18] #[fg=color18, bg=blue] %Y-%m-%d  %R "
set-option -g status-right-style "bg=color18,fg=blue"
set-option -g status-right-length 30

Some of the icons won’t show up or are represented as small empty boxes on Medium and GitHub. Copy the code to have them show up. If they still don’t show up I would recommend using a Nerd-Font — to include the required icons. Here is the full tmux config.

All things considered, tmux is a phenomenal way to organize different windows or panes. Even though it adds another layer to my development workflow, it has increased my productivity and made me more comfortable with the terminal. Hopefully, tmux can also revolutionize your workflow.

--

--

Unixification
Unixification

Published in Unixification

We write about ricing different Unix systems such as macOS, and Linux. Other than Unix systems we write on various tools, like Neovim and Obsidian.

Michael Bao
Michael Bao

Written by Michael Bao

Neovim | Arch Linux | macOS | I love to write about random tech stuff. Tinkering around with Linux, Neovim, and computers.

Responses (4)