Skip to content

Instantly share code, notes, and snippets.

@sadfuzzy
Forked from kaplan/tmux_cheatsheet.markdown
Last active March 4, 2017 14:52
Show Gist options
  • Save sadfuzzy/2de9ae2b51eac1cd7d6754b29f144874 to your computer and use it in GitHub Desktop.
Save sadfuzzy/2de9ae2b51eac1cd7d6754b29f144874 to your computer and use it in GitHub Desktop.
My most commonly used tmux commands and reference sites for learning tmux

tmux handy commands and references

####sessions

tmux new -s session_name      # new session by name
tmux attach -t session_name     # attach session by name (you can also use a instead of attach)
tmux switch -t session_name     # switch session by name (you can also use a instead of attach)
tmux list-sessions              # list existing sessions
bind-key : new -s session_name  # new session from within a session  
// detach
tmux detach                     # detach currently attached session
bind-key :detach                # detach currently attached session
bind-key then hit d             # detach currently attached session

####bind key commands

#default bind key is ctrl+b, but you made it ctrl+a, then hit the following key to execute the command
bind-key ?      # list all key bindings. **This one is key**
bind-key s      # list and choose session
bind-key w      # list and choose window in session
bind-key $      # rename session
bind-key ,      # rename window
bind-key c      # new window within session
bind-key n      # change window within session
bind-key {      # swap pane -U
bind-key }      # swap pane -D
bind-key [      # enter copy mode and you can scroll with j k up down
bind-key q      # leave copy mode
bind-key x      # kill a pane with y/n
bind-key space  # next-layout (swap the split layout)
bind-key '      # give a command-prompt and you can input a window index or name
bind-key %      # Split the current pane into two, left and right.
bind-key "      # Split the current pane into two, top and bottom.

####input commands

bind-key : "break-pane"   # make a pane its own window 

####pane resizing

M denotes the meta key, usually bound to ALT.
On Macs the meta key is usually Esc. 
**In Terminal go Preferences > Keyboard and check 'Use option as meta key'** 
In iTerm2 go Preferences > Keyboard and check 'Use esc as meta key'


bind-key M-Up, M-Down, M-Left, M-Right # resize panes by 5 cells
C-b M-1   # vertical split, all panes same width
C-b M-2   # horizontal split, all panes same height
C-b M-3   # horizontal split, main pane on top, other panes bottom, vertically split, all same width
C-b M-4   # vertical split, main pane left, other panes right, horizontally split, all same height
C-b M-5   # tile, new panes on bottom, same height before same width

####references tmux man page
getting into tmux
http://www.dayid.org
hawkpost: tmux pt1
thoughbot: a tmux crash coarse
Bryan Liles tmux ramble
pane resizing superuser post
screencast pair programming with Tmux

http://jilles.me/tmux-for-developers/

Очень хороший способ запустить tmux: tmux attach || tmux new — делая так, вы сперва пытаетесь подключиться к уже существующему серверу tmux, если он существует; если такого ещё нет — создаёте новый.

После этого вы попадаете в полноценную консоль. Ctrl+b d — отключиться. (Точно так же вы отключитесь, если прервётся соединение. Как подключиться обратно и продолжить работу — см. выше.)

В одной сессии может быть сколько угодно окошек: Ctrl+b c — создать окошко; Ctrl+b 0...9 — перейти в такое-то окошко; Ctrl+b p — перейти в предыдущее окошко; Ctrl+b n — перейти в следующее окошко; Ctrl+b l — перейти в предыдущее активное окошко (из которого вы переключились в текущее); Ctrl+b & — закрыть окошко (а можно просто набрать exit в терминале).

В одном окошке может быть много панелей: Ctrl+b % — разделить текущую панель на две, по вертикали; Ctrl+b " — разделить текущую панель на две, по горизонтали (это кавычка, которая около Enter, а не Shift+2); Ctrl+b →←↑↓ — переходить между панелями; Ctrl+b x — закрыть панель (а можно просто набрать exit в терминале).

Недостаток — непривычным становится скроллинг: Ctrl+b PgUp — вход в «режим копирования», после чего: PgUp, PgDown — скроллинг; q — выход из «режима копирования».

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment