Using CheatSheets To Apply Best Practices

Tmux/Tmate CheatSheet

Tmux/Tmate CheatSheet

1.1 Tmux Basic

Name Comment
Create new session tmux new -s denny
List all sessions tmux ls
Attach to one session tmux attach -t denny
Detach session C-b d
Kill one session tmux kill-session -t denny
List all shortcut keys C-b :list-keys, C-b ? Very useful!
Kill current window C-b &
Default conf file ~/.tmux.conf, ~/.tmate.conf

1.2 Tmux Layout & Scroll

Name Comment
Switch to next pane C-b o
Vertically split pane C-b %
Horizontally split pane C-b “
Kill current pane C-b x
Swap two panes C-b C-o
Resize current pane right C-b :resize-pane -R 20
Resize current pane down C-b :resize-pane -D 10

1.3 Tmux Console Output

Name Comment
Enter copy mode C-b [, press q/Esc to exit
Search output C-b C-s, C-b C-u
Paste buffer to current panel C-b]
Page up/down Enter copy mode, then use normal navigation keys
Show things in current buffer tmux show-buffer
List all buffer tmux list-buffers
Save buffer to file tmux save-buffer foo.txt

1.4 Tmate

Name Comment
see tmate log messages: ssh conn string tmate show-messages
Launch tmate in a detached state tmate -S /tmp/tmate.sock new-session -d
Blocks until the SSH connection is established tmate -S /tmp/tmate.sock wait tmate-ready
Prints tmate SSH connection string tmate -S /tmp/tmate.sock display -p ‘#{tmatessh}’
Make your tmate session big by default Make your default iterm window big

1.5 Scripts

  • Copy to mac clipboard

Note: Only works for the laptop who hosts the tmux/tmate session

brew install reattach-to-user-namespace

# In tmux, search a region. Then save to pbcopy
tmux save-buffer - | reattach-to-user-namespace pbcopy

# In mac terminal

Leave a Reply

Your email address will not be published. Required fields are marked *