Skip to content

Instantly share code, notes, and snippets.

@Yixf-Self
Forked from ursooperduper/tmux-ref.md
Last active August 29, 2015 14:26
Show Gist options
  • Save Yixf-Self/41268f8d769171e81e13 to your computer and use it in GitHub Desktop.
Save Yixf-Self/41268f8d769171e81e13 to your computer and use it in GitHub Desktop.
tmux reference

tmux Reference

Creating Sessions

Command Description
tmux new-session Create new session without a name. (Alt: tmux or tmux new)
tmux new -s development Creates new session called "development."
tmux new -s development -n editor Create new session called "development" and a first window called "editor."
tmux attach -t development Attaches to a session called "development."

Default Commands for Sessions, Windows & Panes

Command Description
PREFIX d Detach from session and leave running.
PREFIX : Command mode.
PREFIX c Create new window in an existing session. Shortcut for new-window
PREFIX 0..9 Select window by number.
PREFIX w Display a seletable list of windows in current session.
PREFIX , Display a prompt to rename window.
PREFIX & Close the current window after prompt to confirm.
PREFIX % Divide the current window in half vertically.
PREFIX " Divide the current window in half horizontally.
PREFIX o Cycle through open panes.
PREFIX q Momentarily display pane numbers in each pane.
PREFIX x Closes the current pane after prompt to confirm.
PREFIX space Cycles through various pane layouts.

Config Info

Command Description
set -g prefix C-a Sets the key combo for PREFIX
set -sg Sets the amount of (in milliseconds) tmux waits for a keystroke after pressing PREFIX.
source-file [file] Loads config file. Use this to reload config.
bind C-a send-prefix Configures tmux to send the prefix when pressing the PREFIX twice in a row.
bind-key [key] [command] Creates keybinding that executes a command. (Shortform: bind)
bind-key -r [key] [command] Creates a repeatable keybinding. This means you can press the PREFIX once, and then hit the assigned key repeatedly.
unbind-key [key] Removes a defined keybinding so it can be reassigned. (Shortform: unbind)
display-message or display Display given text in status
`set-option [flags] [options] [value] Sets options for sesions. Using the -g flag sets options for all sessions.
set-window-option [option] [value] Sets options for windows.
set -a Appends values onto existing options rather than replacing the option's value.

Scriptable tmux Commands

Command Description
tmux new-sessions -s development -n editor Creates a session called "development" and calls the first window, "editor."
tmux attach -t development Attaches to a sessions called "development."
tmux send-keys -t development '[keys]' C-m Sends the keystrokes to the "development" session's active window or pane. C-m is the equivalent of pressing the ENTER key.
tmux send-keys -t development:1.1 '[keys]' C-m Send the keysrokes to the "development" session's first window and first pane, provided the window and pane indexes have been set to 1.
tmux select-window -t development:1 Selects the first window of "development" making it the active window.
tmux split-window -v -p 10 -t development Splits the current window in the "development" session vertically, dividing it in half horizontally and sets it height to 10% of the total window size.
tmux select-layout -t development main-horizontal Sets the layout for the session to main-horizontal.
tmux -f app.conf attach Loads the app.conf config file and attaches it to a session within the app.conf file.

Buffers

Command Description
PREFIX [ Enter Copy mode.
PREFIX ] Paste current buffer contents.
PREFIX = Lists all paste buffers and pastes selected buffer contents.
show-buffer Displays current buffer contents
capture-pane Captures the selected pane's visible contents to a new buffer.
list-buffers Lists all paste buffers
choose-buffer Shows paste buffers and pastes the content of the one you select.
save-buffer [filename] Saves the buffer's contents to the specified filename.

Copy Mode Movement Keys (VI Mode)

Command Description
h, j, j, l Moves the cursor left, down, up, and right, respectively.
w Moves the cursor forward one word at a time.
b Moves the cursor backward one word at a time.
f followed by any character Moves to the next occurrence of the specified character.
F followed by any character Moves to the previous occurrence of the specified character.
CTRL-b Scrolls up one page.
CTRL-f Scrolls down one page.
g Jumps to the top of the buffer.
G Jumps to the bottom of the buffer.
? Starts a search backward through the buffer.
/ Starts a search forward through the buffer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment