tmux
<prefix>
by default is <ctrl> + b
, but with the config below it is rebound to <ctrl> + a
.
Sessions
tmux new -s <session_name> # Create a new named session
tmux ls # List current sessions
tmux attach -t <session_name> # Attach to an existing named session
tmux kill-session -t <session_name> # Kill a session
<prefix> + d # Detach from the current session
<prefix> + ? # List key bindings
Windows
<prefix> + c # Create a new window
<prefix> + , # Change window name
<prefix> + & # Kill the current window
<prefix> + 0-9 # Change to window by number id
Panes
<prefix> + " # Split vertically
<prefix> + % # Split horizontally
<prefix> + x # Kill the current pane
<prefix> + z # Zoom the active pane
<prefix> + ←/→/↑/↓ # Navigate panes with direction arrows
<prefix> & hold <ctrl> + ←/→/↑/↓ # Resize current pane with direction arrows
# hold ctrl and tap arrow for multiple steps
<prefix> + } # Move pane to the right
<prefix> + { # Move pand to the left
<prefix> + <space> # Cycle pane layout options
Copy/Edit Mode
<prefix> + [ # Enter copy/edit mode
<space> # Enter copy mode
<enter> # While in copy mode, saves selection to a buffer
# Custom config below also pipes to system clipboard
<prefix> + ] # Paste buffer
vi mode
? # Search up
/ # Search down
Plugins
tmux-logging
If on macOS using Terminal, make sure to enable “Use Option as Meta Key” in preferences to get access to ‘alt’ via the ‘option’ key.
<prefix> + shift + p # Start/stop logging
<prefix> + alt + shift + p # Capture current history to log file
<prefix> + alt + p # Save visible text (aka text 'screenshot')
tmux Config
~/.tmux.conf based on IppSec’s intro
# set prefix
set -g prefix C-a
bind C-a send-prefix
unbind C-b
# Quality of life
set -g history-limit 10000
set -g allow-rename off
# Window & Pane number starts from 1 (instead of 0)
set -g base-index 1
setw -g pane-base-index 1
# Join Windows
bind-key j command-prompt -p "Join pane from:" "join-pane -s '%%'"
bind-key s command-prompt -p "Send pane to:" "join-pane -t '%%'"
# Search Mode VI (default is emac)
set-window-option -g mode-key vi
# Pipe copy buffer to system clipboard
# Make sure to have xclip installed: sudo apt-get install xclip -y
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
# tmux-logging Plugin
run-shell /opt/tmux-logging/logging.tmux