Skip to content

Instantly share code, notes, and snippets.

@Nuclearfossil
Last active November 29, 2015 14:38
Show Gist options
  • Save Nuclearfossil/c399e24fc29fe31b3f87 to your computer and use it in GitHub Desktop.
Save Nuclearfossil/c399e24fc29fe31b3f87 to your computer and use it in GitHub Desktop.
TMUX cheat-sheet

TMUX cheatsheet

Starting and connecting to tmux

To create an initial tmux instance:

 tmux

With a session name:

 tmux new -s <session name>

Attaching to and existing instance:

 tmux a #
 tmux a -t <session name>

Listing sessions:

 tmux ls

Hotkeys

The default hotkey for tmux is Ctrl-b. However I find Ctrl-j easier to access.

Splitting Panes

nb: these are in my custom .tmux config

 -  Horizontal split
 |  Vertical split
 i  Navigate to the pane directly above
 j  Navigate to the pane to the left
 l  Navigate to the pane to the right
 k  Navigate to the pane directly below
 I  Resize pane up one row
 J  Resize pane to the left one column
 L  Resize pane to the right one column
 K  Resize pane down one row

Windowing

 c  Create new window
 ,  Rename window
 n  Next window
 w  List windows
 

Copy mode:

Pressing PREFIX [ places us in Copy mode. We can then use our movement keys to move our cursor around the screen. By default, the arrow keys work. we set our configuration file to use Vim keys for moving between windows and resizing panes so we wouldn’t have to take our hands off the home row. tmux has a vi mode for working with the buffer as well. To enable it, add this line to .tmux.conf:

setw -g mode-keys vi

With this option set, we can use h, j, k, and l to move around our buffer.

To get out of Copy mode, we just press the ENTER key. Moving around one character at a time isn’t very efficient. Since we enabled vi mode, we can also use some other visible shortcuts to move around the buffer.

For example, we can use "w" to jump to the next word and "b" to jump back one word. And we can use "f", followed by any character, to jump to that character on the same line, and "F" to jump backwards on the line.

   Function                vi             emacs
   Back to indentation     ^              M-m
   Clear selection         Escape         C-g
   Copy selection          Enter          M-w
   Cursor down             j              Down
   Cursor left             h              Left
   Cursor right            l              Right
   Cursor to bottom line   L
   Cursor to middle line   M              M-r
   Cursor to top line      H              M-R
   Cursor up               k              Up
   Delete entire line      d              C-u
   Delete to end of line   D              C-k
   End of line             $              C-e
   Goto line               :              g
   Half page down          C-d            M-Down
   Half page up            C-u            M-Up
   Next page               C-f            Page down
   Next word               w              M-f
   Paste buffer            p              C-y
   Previous page           C-b            Page up
   Previous word           b              M-b
   Quit mode               q              Escape
   Scroll down             C-Down or J    C-Down
   Scroll up               C-Up or K      C-Up
   Search again            n              n
   Search backward         ?              C-r
   Search forward          /              C-s
   Start of line           0              C-a
   Start selection         Space          C-Space
   Transpose chars                        C-t

Misc

# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment