Posted on ::

Install Tmux

$ brew install tmux
# Tmux-based terminal divider
$ brew install tmux-xpanes

Save Tmux config

$ tmux info
$ tmux show -g | sed 's/^/set-option -g /' > ~/.tmux.conf

## Reload config
$ tmux source ~/.tmux.conf

# Kill Tmux server
$ tmux kill-server

Basic Commands

Prefix: Ctrl-b

  • Install Tmux Plugin manager

    # Install plugins
    $ prefix + I
    # Uninstall
    $ prefix + Alt + u
  • Save and Restore Sessions

    $ prefix + Ctrl-s
    $ prefix + Ctrl-r
  • Manage Sessions

    $ tmux new -s code
    $ tmux attach-session -t code
    $ tmux kill-session -t code
    # Kill current session
    $ prefix + :kill-session
    # Detach a session
    $ prefix + d
  • Windows and Sessions

    # Create a new window
    $ prefix + c
    
    # Rename a window
    $ prefix + ,
    
    # Kill a window
    $ Ctrl + d
    $ exit
    $ prefix + &
    
    # Switch to the previous window
    $ prefix + p
    # Switch to the next window
    $ prefix + n
    # Switch to window 1
    $ prefix + 1
    
    $ prefix + w
    $ tmux list-windows
    $ tmux list-sessions
    $ tmux list-clients
    $ tmux ls
    
    # Switch session
    $ prefix + s
    $ prefix + )
    $ prefix + (
  • Window Panes

    # Split window vertically
    $ prefix + %
    # Split window horizontally
    $ prefix + '"'
    # Pane Navigation
    $ prefix + ->,<-,Up,Down
    # Exit pane
    $ exit or  prefix + x
  • Show menu

    $ prefix +  >
  • Mouse Mode

    Click Alt/Option to override the mouse protocol and let you select/paste

    set -g mouse on

Normally Tmux commands can be entered three different ways:

  • By running tmux ... command in a shell inside tmux
  • By hitting Ctrl-b + : in tmux and then entering command into tmux’s command prompt
  • By adding a command into to your ~/.tmux.conf file to bind the key at startup

Key Bindings

  • List Key Bindings

    $ prefix + ?
    $ tmux list-keys

Modifier-Keys

Table of Contents