Tmux Configuration Files

Table of Contents

About

This repository is for storing my tmux configuration files. As usual, I'll try to make this configuration as vanilla as possible. Mostly I only need tmux or screen when I'm accessing a remote machine, create 2 or 3 window at most (Vim/Vi or Emacs, a terminal for logging, and another one for troubleshooting). So it's just a matter of scp-ing this single configuration file to the remote machine, install tmux if not already, and just use it.

Configuration

General Configurations

  • Use tmux-256color if possible
    if 'infocmp -x tmux-256color > /dev/null 2>&1' 'set -g default-terminal "tmux-256color"'
    
  • Screen keybindings
    unbind C-b
    set -g prefix C-a
    bind a send-prefix
    bind a send-prefix
    bind-key C-a last-window
    

    I'm already too familiar with GNU Screen, so C-a is always my prefix key. To make it more Screen-like, C-a C-a will alternate between two latest windows.

  • xterm-keys
    setw -g xterm-keys on
    
  • Automatic Rename

    Rename the window to reflect the current program.

    setw -g automatic-rename on
    
  • Window Renumbering

    Renumber windows when a window is closed.

    set -g renumber-windows on
    
  • Set the terminal title
    set -g set-titles on
    
  • Monitor activity

    Monitor for activity in the window. Windows with activity are highlighted in the status line.

    set -g monitor-activity on
    
  • Visual activity

    If on, display a message instead of sending a bell when activity occurs in a window for which the monitor-activity window option is enabled. If set to both, a bell and a message are produced.

    set -g visual-activity on
    

Key bindings

  • The default keybindings
    C-b Send the prefix key (C-b) through to the application.
    C-o Rotate the panes in the current window forwards.
    C-z Suspend the tmux client.
    ! Break the current pane out of the window.
    " Split the current pane into two, top and bottom.
    # List all paste buffers.
    $ Rename the current session.
    % Split the current pane into two, left and right.
    & Kill the current window.
    ' Prompt for a window index to select.
    ( Switch the attached client to the previous session.
    ) Switch the attached client to the next session.
    , Rename the current window.
    - Delete the most recently copied buffer of text.
    . Prompt for an index to move the current window.
    0 to 9 Select windows 0 to 9.
    : Enter the tmux command prompt.
    ; Move to the previously active pane.
    = Choose which buffer to paste interactively from a list.
    ? List all key bindings.
    D Choose a client to detach.
    L Switch the attached client back to the last session.
    [ Enter copy mode to copy text or view the history.
    ] Paste the most recently copied buffer of text.
    c Create a new window.
    d Detach the current client.
    f Prompt to search for text in open windows.
    i Display some information about the current window.
    l Move to the previously selected window.
    m Mark the current pane (see select-pane -m).
    M Clear the marked pane.
    n Change to the next window.
    o Select the next pane in the current window.
    p Change to the previous window.
    q Briefly display pane indexes.
    r Force redraw of the attached client.
    s Select a new session for the attached client interactively.
    t Show the time.
    w Choose the current window interactively.
    x Kill the current pane.
    z Toggle zoom state of the current pane.
    { Swap the current pane with the previous pane.
    } Swap the current pane with the next pane.
    ~ Show previous messages from tmux, if any.
    Page Up Enter copy mode and scroll one page up.
    Up, Down,Left, Right Change to the pane above, below, to the left, or to the right of the current pane.
    M-1 to M-7 Arrange panes in one of the seven preset layouts: even-horizontal, even-vertical, main-horizontal, main-horizontal-mirrored, main-vertical, main-vertical-mirrored, or tiled.
    Space Arrange the current window in the next preset layout.
    M-n Move to the next window with a bell or activity marker.
    M-o Rotate the panes in the current window backwards.
    M-p Move to the previous window with a bell or activity marker.
    C-Up, C-Down, C-Left, C-Right Resize the current pane in steps of one cell.
    M-Up, M-Down, M-Left, M-Right Resize the current pane in steps of five cells.
  • Clear both screen and history
    bind -n C-l send-keys C-l \; run 'sleep 0.2' \; clear-history
    
  • New Session

    Create a new session,

    bind C-c new-session
    
  • Find session
    bind C-f command-prompt -p find-session 'switch-client -t %%'
    
  • Session navigation

    Move to last session

    bind BTab switch-client -l
    
  • Split window horizontally
    bind - split-window -v
    
  • Split window vertically
    bind _ split-window -h
    
  • Pane Navigation

    Move left.

    bind -r h select-pane -L
    

    Move Down.

    bind -r j select-pane -D
    

    Move Up.

    bind -r k select-pane -U
    

    Move Right.

    bind -r l select-pane -R
    

    Swap current pane with the next one.

    bind > swap-pane -D
    

    Swap current pane with the previous one.

    bind < swap-pane -U
    
  • Pane Resizing
    bind -r H resize-pane -L 2
    bind -r J resize-pane -D 2
    bind -r K resize-pane -U 2
    bind -r L resize-pane -R 2
    
  • Window Navigation

    Select previous window.

    bind C-p previous-window
    

    Select previous window.

    bind p previous-window
    

    Select next window.

    bind C-n next-window
    bind n next-window
    

    Move to last active window.

    bind Tab last-window
    
  • Mouse
    set -g mouse on
    
  • Enter Copy Mode
    bind Enter copy-mode
    
  • Reload config
    bind-key C-r source-file ~/.config/tmux/tmux.conf \; display-message "Tmux config reloaded!"
    
  • Edit config
    bind e new-window -n "~/.config/tmux/tmux.conf" sh -c '${EDITOR:-vim} ~/.config/tmux/tmux.conf && tmux source ~/.tmux.conf && tmux display "~/.config/tmux/tmux.conf sourced"'
    

Date: 2025-04-17 Thu 00:00

Author: Kristian Alexander P

Created: 2025-04-20 Sun 15:12