Skip to content

Instantly share code, notes, and snippets.

@devcfgc
Last active October 30, 2017 11:25
Show Gist options
  • Save devcfgc/ccbb86b06ace56cdd55e96207f6a0f53 to your computer and use it in GitHub Desktop.
Save devcfgc/ccbb86b06ace56cdd55e96207f6a0f53 to your computer and use it in GitHub Desktop.
tmux commands

.tmux.conf

set-option -g allow-rename off set -g status-bg cyan set-option -g prefix C-a unbind C-b

key bindings

tmux may be controlled from an attached client by using a key combination of a prefix key, ‘C-b’ (Ctrl-b) by default, followed by a command key.

  • ? List all key bindings.

  • tmux new -s name_instance --> new session called “name_instance”.
  • d detach from the tmux session.
  • tmux ls --> list existing tmux sessions.
  • tmux new -s name_instance_two -d --> new session instance in the background.
  • tmux attach --> if we only have one session running.
  • tmux attach -t name_instance--> attach to the session name_instance.
  • tmux kill-session -t name_instance --> killing sessions

  • [ enter copy mode and move the cursor to where we want to start selecting text.
  • SPACE and move the cursor to the end of the text and press ENTER (the selected text gets copied into a paste buffer)
  • ] paste the contents we just capture (the current buffer)
  • = Lists all paste buffers and pastes selected buffer contents
  • h , j , k , and 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.

  • " Split the current pane into two, top and bottom.
  • % Split the current pane into two, left and right.
  • o Select the next pane in the current window.
  • x Kill the current pane.
  • C-o Rotate the panes in the current window forwards.
  • ! Break the current pane out of the window.
  • ; Move to the previously active pane.
  • q Briefly display pane indexes.
  • { Swap the current pane with the previous pane.
  • } Swap the current pane with the next pane.

  • $ Rename the current session.
  • tmux new -s <session-name> (if you get some error related to $TMUX us this command - TMUX= tmux new-session -s <session-name>)
  • d Detach from the current session.
  • tmux list-sessions | tmux ls
  • tmux attach -t <session-name> re-attach a session
  • tmux kill-session -t <session-name>

  • c Create a new window.
  • , Rename the current window.
  • w Choose from a list of windows interactively.
  • l Move to the previously selected window.
  • n Change to the next window.
  • p Change to the previous window.
  • & Kill the current window.
  • ' Prompt for a window index to select.
  • f Prompt to search for text in open windows.
  • i Display some information about the current window.
  • 0 to 9 Select windows 0 to 9.

  • : Enter the tmux command prompt.
  • C-b Send the prefix key (C-b) through to the application.
  • C-z Suspend the tmux client.
  • # List all paste buffers.
  • ( Switch the attached client to the previous session.
  • ) Switch the attached client to the next session.
  • - Delete the most recently copied buffer of text.
  • . Prompt for an index to move the current window.
  • = Choose which buffer to paste interactively from a list.
  • D Choose a client to detach.
  • L Switch the attached client back to the last session.
  • [ Enter copy mode to copy text or view the history.
  • ] Paste the most recently copied buffer of text.
  • r Force redraw of the attached client.
  • m Mark the current pane (see select-pane -m).
  • M Clear the marked pane.
  • s Select a new session for the attached client interactively.
  • t Show the time.
  • z Toggle zoom state of the current pane.
  • ~ Show previous messages from tmux, if any.
  • Page Up Enter copy mode and scroll one page up.
  • Up, Down, Left, Right Change to the pane above, below, to the left, or to the right of the current pane.
  • M-1 to M-5 Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
  • Space Arrange the current window in the next preset layout.
  • M-n Move to the next window with a bell or activity marker.
  • M-o Rotate the panes in the current window backwards.
  • M-p Move to the previous window with a bell or activity marker.
  • C-Up, C-Down, C-Left, C-Right Resize the current pane in steps of one cell.
  • M-Up, M-Down, M-Left, M-Right Resize the current pane in steps of five cells.

Key bindings may be changed with the bind-key and unbind-key commands.

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