Tmux

From Grayhat cheatsheets
Jump to navigationJump to search

Tmux: terminal multiplexer.

Start a new session with: tmux new -u session-name

ctrl-r to recursively search for commands (start to write and will autocomplete in real time).

Ctrl-b is the prefix. After it we can pass orders to tmux. In what follows, it will be referred to as c-b.

c-b c adds a new terminal, and we can switch between them with c-b 0, c-b 1, etc.

If for example we have an ssh connection to a host with tmux, we can list the open sessions with tmux ls and do "attach" to one of them with tmux a -t x (to attach to session x in this case).

We can use emacs or vi key bindings with: c-b :set-window-option mode-keys emacs (or vi)

c-b d: detach from current session. c-b ,: rename window. c-b [ for scrolling mode (and we can use re pag, av pag, arrows, etc. We exit this mode pressing q) c-b &: close current window. c-b %: vertical split. c-b ": horizontal split. With c-b and the arrow keys we change the active window, which is highlighted by a green frame. c-b z: to zoom in the active window, or zoom it out. c-b and arrow keys (while still pressing Ctrl), to resize the windows. c-b { or c-b }: to move the windows. c-b space: to change the layout. c-b ?: lists available tmux options. exit: closes the current split (only for 2 or more splits).