Tmux

Updated: January 1, 2026

Tmux is an oldie but goodie for managing many windows & panes in the terminal.

Combined with neovim one can approach having a near vscode feel inside the terminal.
Combine tmux and neovim with nix shell environments to create devshells within
specific folders of a file structure.
In setup we will use a plugin to tie the movements between tmux and neovim so the
keymaps are the same as well as working between the two separate applications.


Table of Contents

Setup

Install

For macOS use brew

brew install tmux

For linux use various pkg manager

pacman -S tmux              # arch
apt install tmux            # debian
devbox add tmux@latest      # devbox (may also select specific version)
nix config                  # best way for nix is declarative

After installing tmux we want to add tpm (tmux plugin manager)
This will allow us to add plugins for extra features. Just run:

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

In the dotfile below is the starter plugin and some good
rock solid plugins. To add/remove a plugin adjust the list
in the dotfile. Then use the commands to maintain them with tpm

Download config file into your home folder

.tmux.conf

# TPM
prefix + I          # install plugins listed in .tmux.conf
prefix + U          # update
prefix alt + u      # uninstall/remove plugins not on list

Commands

tmux uses a prefix key default .
This is only active when inside a session.
You may use ? to list all shortcuts!

# OUTSIDE session
tmux info                           # show every pane, window, session
tmux new -s <name>                  # create a new tmux session (note: all new windows for session will start where this is exec)
tmux ls                             # see list of sessions
tmux detach                         # exit the session
tmux attach, at, a                  # enter most recent session
tmux attach -t <name>               # go into certain session
tmux kill-session -t <name>         # delete a certain session
tmux kill-session -a                # delete all session but current
tmux kill-session -a -t <name>      # delete all sessions but <name>
tmux new-session -A -s <name>       # attach to <name> or create if not exists
tmux popup                          # open popup window (not an editor command but cli)

# INSIDE session
<C-h,j,k,l>     # switch between panes
<C-b>           # prefix key follow by:
    0-9         # swtich between windows

    c           # create a window
    d           # detach from a session
    h,j,k,l     # resize a pane
    m           # maximize a tmux pane
    n           # switch to next window
    p           # switch to previous window
    q           # identify pane numbers
    r           # refresh config file
    s           # show sessions (nav with j,k)
    w           # see all windows
    f           # find window
    o           # next pane
    x           # close a pane
    z           # toggle zoom (maximize a pane)

    I           # install a plugin after doing r

    <space>     # sync all panes (run commands on all at same time)
    PgUp        # enter copy mode and scroll up
    ?           # list key bindings
    |           # split pane vertically (default = %)
    -           # split pane horizontally (default = ")
    :           # enter command mode
    ;           # toggle last active pane
    !           # convert a pane into a window
    &           # close window
    ,           # rename window
    $           # rename session
    [           # copy mode (q to exit)
    {,}         # move panes left or right
    (,)         # previous, next session
    Spacebar    # toggle between pane layouts

    # In copy mode (after <C-b> [ )
    q           # quit copy mode
    g           # go to top
    G           # go to bottom
    h,j,k,l     # move cursor (or arrows)
    w           # forward word
    b           # backward word
    /           # search forward
    ?           # search backward
    n           # next occurrence
    N           # previous occurrence
    Space       # start selection
    Esc         # clear selection
    Enter       # copy selection
    ]           # paste from buffer (outside copy mode)

# tmux command mode (tmux && plugins)
> This is not in terminal nor in nvim command mode!
> They only work after <C-b> :
list-keys                   # same as <C-b> ?
new                         # start a new session
new -s <name>               # start new session with name
rename                      # rename session
rename-window               # rename window
kill-session                # kill current session
attach -d                   # detach others from session
swap-window -s 2 -t 1       # swap source 2 with dest 1
move-window -s <src> -t <dst> # move window
join-pane -s <src> -t <dst> # join panes
setw synchronize-panes      # toggle sync panes
list-buffers                # show buffers
show-buffer                 # show contents of a buffer
capture-pane                # copy visible pane to buffer
choose-buffer               # show buffers and paste selected
save-buffer buf.txt         # copy buffer to file
delete-buffer -b 1          # delete buffer_1
setw -g mode-keys vi        # set vi mode keys
set mouse on                # enable mouse mode

# plugin commands
tmux-resurrect save         # <C-s>
tmux-resurrect restore      # <C-r>
tmux-resurrect list         # list
tmux-resurrect delete       # delete
tmux-resurrect delete-all   # delete all

tmux-continuum on           # turn on auto save
tmux-continuum off          # turn off auto save
tmux-continuum save         # save
tmux-continuum restore      # restore
tmux-continuum list         # list
tmux-continuum delete       # delete
tmux-continuum delete-all   # delete all
tmux-continuum remove <backup-id>   # remove
tmux-continuum save -b <backup-id>  # force save

# Misc commands
set -g <option>              # set global option
setw -g <option>             # set window option