Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Last active October 26, 2021 17:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save RichardBronosky/fd0fe5006271b521d12e8d9de9f2c806 to your computer and use it in GitHub Desktop.
Save RichardBronosky/fd0fe5006271b521d12e8d9de9f2c806 to your computer and use it in GitHub Desktop.
TMUX cheat sheet
# Use vi default bind-keys
setw -g mode-keys vi
# Use zsh inside tmux panes
tmux set-option default-command "/usr/bin/env zsh"
# Make @ do the opposite of !
bind-key @ list-windows; command-prompt -p "create pane from:" "join-pane -s ':%%'"

TMUX cheat sheet

Standard Bindings

Binding Mode Action

Ctrl+b, :

default

Enter command mode/prompt

Ctrl+b, Ctrl+[

default

Enter copy mode

Ctrl+b, Ctrl+]

default

Paste buffer

Ctrl+b, #

default

List all paste buffers

Ctrl+b, $

default

Rename the current session

Ctrl+b, !

default

Break the current pane out of the window

Ctrl+b, "

default

Split the current pane into two, top and bottom

Ctrl+b, %

default

Split the current pane into two, left and right

Ctrl+b, &

default

Kill the current window

Modified Bindings

Binding Mode Action

bind-key @ list-windows; command-prompt -p "create pane from:" "join-pane -s ':%%'"

Ctrl+b, @

default

Create new pane from existing window

Misc

SSH agent forwarding inside a re-attached tmux session

# Before launching tmux
sed -i '/SSH_AUTH_SOCK/d' ~/vars.txt
echo -n 'export ' >> ~/vars.txt
env | awk '/SSH_AUTH_SOCK/{print; exit}' >> ~/vars.txt

# Launch tmux
tmux attach || tmux

# Retreive vars inside tmux
source ~/vars.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment