Skip to main content

Tmux Cheatsheet


Tmux Cheatsheet

Key Bindings:

  • Prefix Key Change:
    • prefix + C-a: Changes the prefix to Ctrl-a.

Window and Pane Management:

  • Create New Window:
    • prefix + e: Creates a new window and opens ~/.tmux.conf.local for editing.
  • Split Pane Vertically:
    • prefix + -: Splits the current pane vertically.
  • Split Pane Horizontally:
    • prefix + |: Splits the current pane horizontally.
  • Resize Pane:
    • prefix + H: Resizes pane left by 2 cells.
    • prefix + J: Resizes pane down by 2 cells.
    • prefix + K: Resizes pane up by 2 cells.
    • prefix + L: Resizes pane right by 2 cells.

Session Management:

  • Create New Session:
    • prefix + C-c: Creates a new session.
  • Find and Switch Session:
    • prefix + C-f: Prompts to find and switch to a session.
  • Reload Tmux Configuration:
    • prefix + r: Reloads the Tmux configuration.

Mouse Management:

  • Toggle Mouse Mode:
    • prefix + m: Toggles mouse mode on/off, allowing you to interact with Tmux using the mouse.

Copy Mode (vi key bindings):

  • Initiate Regex Search:

    • prefix + /: Initiates regex search (strings work too).
  • Predefined Searches:

    • prefix + C-f: Simple file search.
    • prefix + C-g: Jumping over git status files (best used after git status command).
    • prefix + M-h: Jumping over SHA-1/SHA-256 hashes (best used after git log command).
    • prefix + C-u: URL search (http, ftp, and git URLs).
    • prefix + C-d: Number search (mnemonic d, as digit).
    • prefix + M-i: IP address search.

Copycat Mode Bindings:

  • Navigate Matches:
    • n: Jumps to the next match.
    • N: Jumps to the previous match.
  • Copy Highlighted Match:
    • Enter (in Tmux vi mode) or C-w/M-w (in Tmux emacs mode): Copies a highlighted match and exits copycat mode.

Pasting:

  • Paste Copied Text:
    • prefix + ]: Pastes the last copied text.

Plugin Management:

  • Install or Refresh Plugins:
    • prefix + I: Installs new plugins or refreshes the Tmux environment.
  • Update Plugins:
    • prefix + U: Updates plugins.
  • Remove/Uninstall Plugins:
    • prefix + M-u: Removes/uninstalls plugins not on the plugin list.

Examples for Search Entries:

  • String Search:
    • foo: Searches for the string "foo".
  • Regex Search for Numbers:
    • [0-9]+: Regex search for numbers.

The searches are performed using grep and are case insensitive.

Advanced Usage:

  • Reload Tmux Configuration: Keep your Tmux configuration updated by reloading the configuration file after changes.

    • prefix + r: Reloads the Tmux configuration file, applying any changes made.
  • Run Shell Command: Execute shell commands directly from Tmux for quick tasks or checking system information.

    • prefix + :: Opens the Tmux command prompt, followed by run "your-command" to execute the shell command.
  • Nested Tmux Session: Use nested Tmux sessions for complex workspace management or remote session handling.

    • Start a new Tmux session, then within that session, initiate another Tmux session. This way, you can manage multiple, independent Tmux sessions within one terminal.

Online Resources:

  • Tmux GitHub Repository: Get the latest version, report issues or contribute to Tmux development.
  • Tmux User Wiki: A community-driven platform with tips, tricks, and configuration examples.