Advertisement
luxaeterna101

tmux cheat sheet

Apr 1st, 2015
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. # tmux cheat sheet
  2.  
  3. (C-x means ctrl+x, M-x means alt+x)
  4.  
  5.  
  6. ## Prefix key
  7.  
  8. The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to `~/.tmux.conf`:
  9.  
  10. # remap prefix to Control + a
  11. set -g prefix C-a
  12. # bind 'C-a C-a' to type 'C-a'
  13. bind C-a send-prefix
  14. unbind C-b
  15.  
  16. I'm going to assume that C-a is your prefix.
  17.  
  18.  
  19. ## Sessions, windows, panes
  20.  
  21. Session is a set of windows, plus a notion of which window is current.
  22.  
  23. Window is a single screen covered with panes. (Once might compare it to a ‘virtual desktop’ or a ‘space’.)
  24.  
  25. Pane is a rectangular part of a window that runs a specific command, e.g. a shell.
  26.  
  27.  
  28. ## Getting help
  29.  
  30. Display a list of keyboard shortcuts:
  31.  
  32. C-a ?
  33.  
  34. Navigate using Vim or Emacs shortcuts, depending on the value of `mode-keys`. Emacs is the default, and if you want Vim shortcuts for help and copy modes (e.g. j, k, C-u, C-d), add the following line to `~/.tmux.conf`:
  35.  
  36. setw -g mode-keys vi
  37.  
  38. Any command mentioned in this list can be executed as `tmux something` or `C-a :something` (or added to `~/.tmux.conf`).
  39.  
  40.  
  41. ## Managing sessions
  42.  
  43. Creating a session:
  44.  
  45. tmux new-session -s work
  46.  
  47. Create a new session that shares all windows with an existing session, but has its own separate notion of which window is current:
  48.  
  49. tmux new-session -s work2 -t work
  50.  
  51. Attach to a session:
  52.  
  53. tmux attach -t work
  54.  
  55. Detach from a session: `C-a d`.
  56.  
  57. Switch between sessions:
  58.  
  59. C-a ( previous session
  60. C-a ) next session
  61. C-a L ‘last’ (previously used) session
  62. C-a s choose a session from a list
  63.  
  64. Other:
  65.  
  66. C-a $ rename the current session
  67. C-a
  68.  
  69.  
  70. ## Managing windows
  71.  
  72. Create a window:
  73.  
  74. C-a c create a new window
  75.  
  76. Switch between windows:
  77.  
  78. C-a 1 ... switch to window 1, ..., 9, 0
  79. C-a 9
  80. C-a 0
  81. C-a p previous window
  82. C-a n next window
  83. C-a l ‘last’ (previously used) window
  84. C-a w choose window from a list
  85.  
  86. Switch between windows with a twist:
  87.  
  88. C-a M-n next window with a bell, activity or
  89. content alert
  90. C-a M-p previous such window
  91.  
  92.  
  93. Other:
  94.  
  95. C-a , rename the current window
  96. C-a & kill the current window
  97.  
  98.  
  99. ## Managing split panes
  100.  
  101. Creating a new pane by splitting an existing one:
  102.  
  103. C-a " split vertically (top/bottom)
  104. C-a % split horizontally (left/right)
  105.  
  106. Switching between panes:
  107.  
  108. C-a left go to the next pane on the left
  109. C-a right (or one of these other directions)
  110. C-a up
  111. C-a down
  112. C-a o go to the next pane (cycle through all of them)
  113. C-a ; go to the ‘last’ (previously used) pane
  114.  
  115. Moving panes around:
  116.  
  117. C-a { move the current pane to the previous position
  118. C-a } move the current pane to the next position
  119. C-a C-o rotate window ‘up’ (i.e. move all panes)
  120. C-a M-o rotate window ‘down’
  121. C-a ! move the current pane into a new separate
  122. window (‘break pane’)
  123. C-a :move-pane -t :3.2
  124. split window 3's pane 2 and move the current pane there
  125.  
  126. Resizing panes:
  127.  
  128. C-a M-up, C-a M-down, C-a M-left, C-a M-right
  129. resize by 5 rows/columns
  130. C-a C-up, C-a C-down, C-a C-left, C-a C-right
  131. resize by 1 row/column
  132.  
  133. Applying predefined layouts:
  134.  
  135. C-a M-1 switch to even-horizontal layout
  136. C-a M-2 switch to even-vertical layout
  137. C-a M-3 switch to main-horizontal layout
  138. C-a M-4 switch to main-vertical layout
  139. C-a M-5 switch to tiled layout
  140. C-a space switch to the next layout
  141.  
  142.  
  143. Other:
  144.  
  145. C-a x kill the current pane
  146. C-a q display pane numbers for a short while
  147.  
  148.  
  149. ## Other config file settings
  150.  
  151. Force a reload of the config file on C-a r:
  152.  
  153. unbind r
  154. bind r source-file ~/.tmux.conf
  155.  
  156. Some other settings that I use:
  157.  
  158. setw -g xterm-keys on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement