Refer

Commands

Lang: sh
# sessions
# create new session
tmux # or
tmux new
tmux new-session
tmux new -s <session_name>

# attach to session
tmux a
tmux at
tmux attach
tmux attach-session
tmux a -t <session_name>
tmux attach -t <session_name>

# kill session
tmux kill-ses
tmux kill-session
tmux kill-session -t <session-name>
# kill all sessions but the current/<session-name>
tmux kill-session -a
tmux kill-session -a -t <session-name>

# list sessions
tmux ls

# Show every session, window, pane, etc
tmux info

# List key bindings(shortcuts)
tmux list-keys

Keymaps

Lang: text
tmux prefix
default: (Ctrl + b)

change using:
set -g prefix <prefix-keys>

sessions:
Detach a session
(Ctrl + b) + d
Rename session
[Shortcut]
(Ctrl + b) + $
[In cmd mode]
:rename-session -t [current-name] [new-name]
Kill session
(Ctrl + b) + :
[In cmd mode]
:kill-session # kill default session
:kill-session -t [other-session]

windows:
Create a new window
(Ctrl + b) + c
Rename current window
Ctrl + b + ,
Switch between the windows
(Ctrl + b) + n (Next window)
(Ctrl + b) + p (Previous window)
List all windows and select
(Ctrl + b) + w
Delete the current window
(Ctrl + b) + &
Reorder window
(Ctrl + b) + (:swap-window -s 2 -t 1)
  # swap window number 2(src) and 1(dst)
Move current window to the left by one position
(Ctrl + b) + (:swap-window -t -1)
Renumber current window
(Ctrl + b) + .

panes:
Create pane
(Ctrl + b) + “ - horizontal
Create pane
(Ctrl + b) + % - vertical
Change panes
(Ctrl + b) + o (Rotate clockwise)
Close current pane
(Ctrl + b) + x
Toggle last active pane
(Ctrl + b) + ;
Move the current pane left
(Ctrl + b) + {
Move the current pane right
(Ctrl + b) + }
Switch to pane to the direction
(Ctrl + b) + (Arrow Keys)
Toggle synchronize-panes(send command to all panes)
(Ctrl + b) + (:setw synchronize-panes)
Toggle between pane layouts
(Ctrl + b) + (Space Key)
Show pane numbers:
(Ctrl + b) + q
Switch/select pane by number
(Ctrl + b) + q + (0...9)
Convert pane into a window
(Ctrl + b) + !
Resize current pane height(holding second key is optional)
(Ctrl + b) + (up / ctrl + up)
(Ctrl + b) + (dn / ctrl + dn)
Resize current pane width(holding second key is optional)
(Ctrl + b) + (rt / ctrl + rt)
(Ctrl + b) + (lt / ctrl + lt)
Resize equal panes - vertical
[Shortcut]
(Ctrl+b) + (Alt+1)
[In cmd mode]
:select-layout even-vertical
Resize equal panes - horizontal
[Shortcut]
(Ctrl+b) + (Alt+2)
[In cmd mode]
:select-layout even-horizontal

# TODO: Add key-binding to capture pane contents to file
# Capture pane content to a file.
:capture-pane -S - # capture all lines into default buffer
:save-buffer $PWD/filename # write default buffer to file in $PWD

scrolling:
(Ctrl + b) + [ # Scroll up/down
[In scroll mode] q - Quit scroll mode

misc:
Enter command mode
(Ctrl + b) + :
Enable mouse mode
[In cmd mode] :set mouse on

tmux copy mode key bindings:
$ tmux list-keys -T copy-mode-vi
# inside tmux session
(Ctrl+b) + :list-keys -T copy-mode-vi

tmux copy mode, copy text within tmux panes/windows:
* Enter copy mode
  (Ctrl+b) + [
* Select text using
  (Ctrl+space)
* Write into tmux buffer
  (Ctrl+w) or (Alt+w)
* Paste in a possibly different Tmux pane/window
  (Ctrl+b) + ]