Tmux

From Han Wiki
Jump to navigation Jump to search

Tmux

Sessions refer to multiple instances of tmux running, and window refers to the shell console in each of the session.

shell commands

Reattaching an existing session

$ tmux ls
0: 2 windows (created Fri Aug 11 15:14:08 2023) [232x52]
$ tmux attach -d -t 0

keyboard shortcuts

General

Ctrl + B - the default leader key

[Leader] ? - help menu

[Leader] ~ - display system msgs for the current session

[Leader] [Leader] - send the leader key through the terminal

[Leader] : - command buffer

[Leader] Ctrl + Z - suspend current tmux client

[Leader] D - detach the current session from the active terminal

[Leader] Shift + D - open a prompt to select which session to attach

[Leader] S - switch to a different session

[Leader] ( - move current client to the previous session

[Leader] ) - move current client to the next session

[Leader] R - redraw the current screen

[Leader] T - show the current time

Window Management

[Leader] C - create a new window

[Leader] & - delete the currently selected window

[Leader] I - briefly display info about the currently selected window

[Leader] N - go to the next window in the session

[Leader] P - go to the previous window in the session

[Leader] Alt+N - go to the next window w/ a marker

[Leader] Alt+P - go to the previous window w/ a marker

[Leader] , - change the label of the current window

[Leader] . - change the index number of the current window

[Leader] L - go to the previously selected window

[Leader] 0 - 9 - go to the window with the corresponding index number

[Leader] ' - open a prompt to directly switch to a specific index number

[Leader] W - open a propmt to interactively select the window to switch to

[Leader] F - search for windows that contain a specific text string

Pane management

[Leader] Q - show the pane index for the currently visible screen

[Leader] % - create a new vertically split pane in the current window

[Leader] " - create a new horizontally split pane in the current window

[Leader] X - delete the currently selected pane

[Leader] ! - put the currently selected pane to a different window

[Leader] ; - select the previously active pane

[Leader] M - mark the current pane

[Leader] Shift + M - unmark the current pane

[Leader] O - select the next pane in the currently selected window

[Leader] { - swap the currently selected pane with the previous one in the index

[Leader] } - swap the currently selected pane with the next one in the index

[Leader] Up - select the pane above the currently selected pane

[Leader] Down - select the pane below the currently selected pane

[Leader] Left - select the pane left of the currently selected pane

[Leader] Right - select the pane right of the currently selected pane

Pane layouts

[Leader] Alt + 1 - arrange the layout of the panes in the current window to a horizontally stacked layout

[Leader] Alt + 2 - ... vertically stacked layout

[Leader] Alt + 3 - ... horizontal master-stack layout

[Leader] Alt + 4 - ... vertical master-stack layout

[Leader] Alt + 5 - ... tiled layout

[Leader] Space - Cycle through all of the default layouts in the current window

[Leader] Ctrl + Up - increase the size of the currently selected pane by one row upwards

[Leader] Ctrl + Down - increase the size of the currently selected pane by one row downwards

[Leader] Ctrl + Left - increase the size of the currently selected pane by one column leftwards

[Leader] Ctrl + Right - increase the size of the currently selected pane by one column rightwards

Text copy mode

[Leader] [ - switch the current session to tmux's text copy mode

G - go to the top line of the current window

Shift + G - go to the bottom line of the current window

/ - do a forward search

? - do a backward search

N - highlight the next occurrence of the keyword

Shift + N - highlight the previous occurrence of a keyword

K or Up Arrow - move the cursor one line upwards

J or Down Arrow - move the cursor one line downwards

H or Left Arrow - move the cursor one character leftwards

L or Right Arrow - move the cursor one character rightwards

W - move the cursor one word forward

B - move the cursor one word backward

Ctrl + Space - start the text selection at the current point

Ctrl + W - copy the selected text to the paste buffer

[Leader] ] - paste the contents of the last buffer to the current window

[Leader] = - open the list of currently active sessions and select where to paste the current selection