Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Last active December 10, 2019 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshschmelzle/2808e55d4881b8807a7f2dcee286cb94 to your computer and use it in GitHub Desktop.
Save joshschmelzle/2808e55d4881b8807a7f2dcee286cb94 to your computer and use it in GitHub Desktop.
tmux notes and cheatsheet

tmux

it's a terminal multiplexer that allows access to multiple terminal sessions in a single window. so, you can split terminals into panes. you can move, resize, and switch between them.

it's also useful for detaching processes from the controlling terminal. so, a SSH session can remain active without actually being visible. i recommend using tmux if you're doing remote work via ssh.

tmux hotkeys to help with remote ssh dev

install tmux with sudo apt install tmux.

shortcuts:

tmux -V                   # show version
tmux                      # launch tmux
tmux new -s mysessionname # start new session with a name
tmux a -t mysessionname   # attach to a named session
tmux ls                   # show list of tmux sessions
tmux a                    # attach
tmux attach -t 0          # reattach to a running tmux session
tmux kill-session -t 0    # end/kill session
CTRL+B, z                 # toggle current pane full screen
CTRL+B, c                 # add a new window
CTRL+B, n                 # move to next window
CTRL+B, p                 # move to previous window
CTRL+B, ,                 # rename current window
CTRL+B, q                 # show pane numbers
CTRL+B, w                 # list windows and their numbers
CTRL+B, <window number>   # move to window number

panes

CTRL+B, %                 # horizontal split 
CTRL+B, "                 # vertical split 
CTRL+B, d                 # detach from and end session
CTRL+B, x                 # kill the current pane
CTRL+B, o                 # next pane
CTRL+B, {                 # move pane left
CTRL+B, }                 # move pane right
CTRL+B, ;                 # previous pane
CTRL+B, <UP ARROW>        # switch between panes
CTRL+B, <DOWN ARROW>      # switch between panes
CTRL+B, <LEFT ARROW>      # switch between panes
CTRL+B, <RIGHT ARROW>     # switch between panes

scrolling in pane

1. CTRL+B
2. [
3. Arrow keys or Shift + Page up/down
4. Control+C when donw with scrollback

config

don't like CTRL+B binding? you can rebind/remap it. Add set -g prefix C-a to your config.

~/.tmux.conf
tmux source-file ~/.tmux.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment