Back to Blog

The Zen Tmux Configuration

Dreams of Code Logo
Dreams of Code
May 22, 2025
The Zen Tmux Configuration

The Zen of Tmux: Creating a Modern, Minimal Terminal Multiplexer Setup

A guide to transforming the terminal multiplexer into a modern, productivity-boosting tool

Tmux is perhaps the one piece of software that's had the biggest impact on the way I write code. Out of the box, however, Tmux can be difficult to look at and requires a little bit of configuration to really get productive with. In this guide, I'll explain why Tmux is so powerful and show you how to update it from its default offering into a version that is modern, zenful, and a joy to work with.

Why Tmux Changed My Workflow

I really meant it when I said that Tmux has had one of the biggest impacts on the way I write code. Before discovering it, I worked more with IDEs and graphical editors and only entered the terminal when I needed to. Once I discovered Tmux, that all changed. My default editor became Vim, and I was able to have all of the goodness of a tiling window manager in the terminal.

Tmux provides essential features for working in a command line that I just can't live without:

  • Creating and managing new windows for multiple terminal sessions
  • Splitting a window into panes so that I can have multiple sessions in one view
  • Preventing my workspace from being lost if my terminal crashes (or more likely, if I accidentally close it)
  • Enabling remote work—if I want to do my favorite nighttime activity, bed coding, I can pick up my laptop, SSH into my desktop, and attach to my previous Tmux session

Over the years, I've built up a configuration that works really well for me, which I'm excited to share with you today.

For a comprehensive overview of Tmux's capabilities, check out the official Tmux GitHub repository and the Tmux wiki.

Getting Started with Tmux

Before we start writing our Zenful configuration, we need to do a little preparation:

  1. Install Tmux - As of the time of writing, the latest version is 3.3a. Install it according to your operating system's package manager.
  • Ubuntu/Debian: sudo apt install tmux
  • macOS (Homebrew): brew install tmux
  • Arch Linux: sudo pacman -S tmux
  • For other systems, see the Tmux installation docs
  1. Install Tmux Package Manager (TPM) - You'll need Git for this. Install TPM with:
bash
   git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

Visit the TPM GitHub page for more information.

  1. Create Your Tmux Config File - You can create this at either:
  • ~/.tmux.conf

  • $XDG_CONFIG_HOME/tmux/tmux.conf (typically ~/.config/tmux/tmux.conf)

    I prefer the XDG config approach as it's the more modern way to manage dotfiles. Learn more about XDG Base Directory specification.

  1. Initialize TPM - Open your config file and add:
bash
   # List of plugins
   set -g @plugin 'tmux-plugins/tpm'
   set -g @plugin 'tmux-plugins/tmux-sensible'

   # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
   run '~/.tmux/plugins/tpm/tpm'

The tmux-sensible plugin sets numerous options that fix some quirks with Tmux's default configuration. If you want to know more about what options this package changes, check out the tmux-sensible GitHub page.

With our initial config set, we can run Tmux to load it. If you're already in Tmux, reload the configuration with:

bash
tmux source ~/.config/tmux/tmux.conf  # Adjust path as needed

Understanding Tmux Basics

Before diving deeper into configuration, it's helpful to understand some basic Tmux concepts and commands:

Core Concepts

Tmux consists of three main components:

  1. Sessions - The topmost layer, a collection of one or more windows managed as a single unit. You can have multiple sessions but are typically attached to only one at a time.
  2. Windows - Containers for one or more panes, similar to tabs in browsers. Windows in a session are shown at the bottom of the screen with the active one marked by an asterisk.
  3. Panes - Splits within a window, each representing an individual terminal session. Only one pane is active at a time for input.

Basic Commands

To enter commands in Tmux, you use a prefix key (default: Ctrl+b) followed by a specific key for the command:

Window Management

  • Create new window: Prefix + c
  • Switch to window by number: Prefix + [number]
  • Next/previous window: Prefix + n / Prefix + p
  • Swap windows: Prefix + :swap-window -t [target]
  • Close window: Prefix + &

Pane Management

  • Split horizontally: Prefix + %
  • Split vertically: Prefix + "
  • Navigate between panes: Prefix + [arrow key]
  • Swap panes: Prefix + { or Prefix + }
  • Show pane numbers: Prefix + q (then press the number to select)
  • Zoom into pane: Prefix + z
  • Convert pane to window: Prefix + !
  • Close pane: Prefix + x

Session Management

  • Create session: tmux new -s [name]
  • List sessions: tmux ls or Prefix + s when inside Tmux
  • Attach to session: tmux attach -t [name]
  • Preview windows for all sessions: Prefix + w

For a more comprehensive reference, check out tmuxcheatsheet.com or the official Tmux documentation.

Building Our Zen Tmux Configuration

Now that we understand the basics, let's build our improved configuration step-by-step.

1. Vim-Style Navigation with Tmux Navigator

One of the first improvements I make is setting up better key bindings for navigating around Tmux with the vim-tmux-navigator package. This provides two key benefits:

  1. Moving between split panes using Ctrl + h/j/k/l (vim-style navigation)
  2. Seamless integration between Tmux and Neovim by installing it as a Neovim plugin too

First, add the plugin to your Tmux config:

bash
set -g @plugin 'christoomey/vim-tmux-navigator'

Then install it in Tmux by pressing Prefix + I.

If you use Neovim, you'll want to install it there too. For NvChad users:

lua
-- Add to your custom plugins file
{
  "christoomey/vim-tmux-navigator",
  lazy = false,
}

-- You may need to add custom mappings if your Neovim config overrides these

Now you can navigate between Tmux panes and Neovim splits with the same keys: Ctrl + h/j/k/l.

For more details, visit the vim-tmux-navigator GitHub page. If you're interested in my Neovim configuration, check out my Neovim setup guide.

2. Window Navigation Shortcuts

I also like to add custom key bindings for navigating between windows. Add these lines to your config:

bash
# Navigate windows with Shift+Alt+h and Shift+Alt+l
bind -n M-H previous-window
bind -n M-L next-window

3. Fix Colors in Tmux

To ensure proper color support in Tmux (especially important for Neovim themes), add:

bash
# Enable 24-bit color support
set-option -sa terminal-overrides ",xterm*:Tc"

4. Change the Prefix Key

The default Ctrl+b prefix can conflict with other terminal functionality. I prefer Ctrl+Space:

bash
# Remap prefix from 'C-b' to 'C-Space'
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix

5. Install Catppuccin Theme

Time to replace that horrible green status line with something beautiful. Catppuccin is my favorite theme, and it offers a Tmux plugin:

bash
set -g @plugin 'catppuccin/tmux'
set -g @catppuccin_flavour 'mocha' # or latte, frappe, macchiato

If you prefer my fork with more window tab information:

bash
set -g @plugin 'dreamsofcode-io/catppuccin-tmux'

For more information on Catppuccin and its various "flavors," visit the Catppuccin GitHub repository and the Catppuccin Tmux plugin page.

6. Enable Mouse Support

Add mouse support to click on panes/windows and scroll through buffer history:

bash
# Enable mouse control
set -g mouse on

7. Start Window and Pane Numbering at 1

By default, Tmux starts indexing windows and panes at 0, which isn't intuitive for keyboard navigation:

bash
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1

8. Improve Copy Mode with Tmux Yank

The tmux-yank package enhances the copy experience:

bash
set -g @plugin 'tmux-plugins/tmux-yank'

Let's also make copy mode more vim-like:

bash
# Vi mode
set-window-option -g mode-keys vi

# Vim-style copy mode bindings
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

Now in copy mode (entered with Prefix + [) you can:

  • Press v to start selection
  • Press y to copy
  • Press Ctrl+v to toggle between rectangle/line selection

For more information on the tmux-yank plugin and its capabilities, visit the tmux-yank GitHub page.

9. Open New Panes in Current Directory

Lastly, I configure new panes to open in the same directory I'm currently in:

bash
# Open splits in current directory
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"

The Complete Configuration

Here's the complete configuration we've built:

bash
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'dreamsofcode-io/catppuccin-tmux'
set -g @plugin 'tmux-plugins/tmux-yank'

# Enable mouse support
set -g mouse on

# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1

# Remap prefix from 'C-b' to 'C-Space'
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix

# Navigate windows with Shift+Alt+h and Shift+Alt+l
bind -n M-H previous-window
bind -n M-L next-window

# Enable 24-bit color support
set-option -sa terminal-overrides ",xterm*:Tc"

# Set Catppuccin theme
set -g @catppuccin_flavour 'mocha' # or latte, frappe, macchiato

# Vi mode
set-window-option -g mode-keys vi

# Vim-style copy mode bindings
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

# Open splits in current directory
bind '"' split-window -v -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Conclusion

With this configuration, you now have a Tmux setup that is both productive and a joy to work with. The improvements provide:

  • A modern and aesthetically pleasing interface with Catppuccin theme
  • Intuitive Vim-like navigation between panes
  • Better window management with custom key bindings
  • Enhanced copy mode that feels familiar to Vim users
  • Practical quality-of-life improvements for daily use

I hope this guide inspires you to try Tmux yourself or upgrade your existing configuration. Remember, the beauty of Tmux is that it's highly customizable—you can adapt this configuration to match your personal workflow.

If you have other plugins or tweaks you think should be included, please let me know. Happy terminal multiplexing!

Additional Resources


Note: You can find my complete Tmux configuration in my dotfiles repository on GitHub.

Get Support