Home Tmux
Post
Cancel

Tmux

Introduction

Tmux is a terminal multiplexer that allows you to manage multiple terminal sessions from a single window. It’s extremely useful for developers and system administrators for multitasking in the command line environment.

Install Tmux using Homebrew:

1
brew install tmux

Tmux Shortcuts and Commands

Starting, Detaching, and Attaching Sessions

  • Start new session:
    1
    
    tmux
    
  • Start new named session:
    1
    
    tmux new -s session_name
    
  • Detach from session:
    • Ctrl-b then d
  • List sessions:
    1
    
    tmux ls
    
  • Attach to session:
    1
    
    tmux attach -t session_name
    
  • Attach to the last session:
    1
    
    tmux attach
    

Window Management

  • Create new window:
    • Ctrl-b then c
  • Switch to window by number (e.g., window 1):
    • Ctrl-b then 1
  • Rename current window:
    • Ctrl-b then ,
  • Close current window:
    • Ctrl-d or exit the shell

Pane Management

  • Split pane horizontally:
    • Ctrl-b then %
  • Split pane vertically:
    • Ctrl-b then "
  • Navigate between panes:
    • Ctrl-b then use arrow keys
  • Resize panes:
    • Ctrl-b then hold Ctrl and use arrow keys
  • Close current pane:
    • Ctrl-d or exit the shell in the pane

Session Environment

  • Reload tmux configuration:
    1
    
    tmux source-file ~/.tmux.conf
    
  • Show all key bindings:
    1
    
    tmux list-keys
    
  • Show system information:
    • Ctrl-b then i

Miscellaneous

  • Enter command mode:
    • Ctrl-b then :
  • Capture pane content to a file:
    1
    
    tmux capture-pane -t 0 -S - -E - -p > file.txt
    
  • Scroll mode (copy mode):
    • Ctrl-b then [, then navigate using arrow keys, q to exit

Customizing Tmux

  • Tmux is highly customizable through the .tmux.conf file in the user’s home directory. You can set key bindings, appearance, and behavior according to your preference.
This post is licensed under CC BY 4.0 by the author.