Skip to content

Instantly share code, notes, and snippets.

@lambda-mike
Last active August 11, 2022 13:37
Show Gist options
  • Save lambda-mike/a5abe12deba966a9248548f4cc382909 to your computer and use it in GitHub Desktop.
Save lambda-mike/a5abe12deba966a9248548f4cc382909 to your computer and use it in GitHub Desktop.
My Tmux cheatsheet

Tmux cheatsheet

https://tmuxcheatsheet.com/

All lines bleow should start with tmux

ls # list-sessions

new -s "bee"   #new-session

new -Asmysession # reattach; otherwise create; -D # detach other clients

kill-session -t "bee"    # t is target

attach -t "bee"  # or 0 default session, left blan - last session

rename -t 0 pinguin # rename-session

locks -t "bee" #lock-session`

saveb # Save the contents of the specified paste buffer to path.  The -a option appends to rather than overwriting the file

source ~/.tmux.conf   # source config file when tmux is running

set -w synchronize-panes # write in multiple panes the same time

neww -dnmynewwindow # new named window not focused

movew -r   # renumber windows

setb -bbuffer0 -nmybuffer   # **naming buffers**

loadb -bbuffername ~/a/file # load buffer from the file

saveb -bbuffer0 ~/saved_buffer # save buffer to a file

tmux lsk -Tprefix  # display keys from prefix table

set -gu status # restore to default (unset)

respawn-pane # or window

Keybindings

Ctrl+b (prefix)

? - help

d - detach from session

0123... - switch to window 0, 1, ...

c - create new window

, - rename window

% - split horizontally

" - split vertically

z - zoom in/out (toggle)

arrow - move between panes when prefix; hold - resize

alt+arrow - Resize the current pane in steps of five cells.

n - to select the next window

p - to select the previous window

{ - move pane to the left

} - move pane to the right

space - toggle layout round robin

q - query for pane numbers (display them) and switch when number pressed

C-o swaps that pane with the active pane, so they exchange positions and sizes in the window.

t - display time :)

w - Choose the current window interactively (searching works).

' - choose the index/name of the window

x - Kill the current pane.

D - list clients to detach (d)

[ - enter copy mode

] - paste from the copy buffer

'#' - list copy buffers

= - choose a copy buffer from the list

Copy pasta

Ctrl+b [ - Enter copy mode

Ctrl+b ] - paste

space - copy mode

scroll, move, etc.

Enter - copy to buffer

q - cancel copy moge

Escape - Clear selection

v - Toggle rectangle selection

https://www.maketecheasier.com/manage-restore-tmux-sessions-linux/

https://github.com/tmux-plugins/tmux-resurrect

https://www.sitepoint.com/10-killer-tmux-tips/

split-window -h -v -b (split on the left/top not right/bottom -d do not focus new pane -f span whole heigth/width

Items in the tree are tagged by pressing t and untagged by pressing t again. Tagged items are shown in bold and with * after their name. All tagged items may be untagged by pressing T. Tagged items may be killed together by pressing X, or a command applied to them all by pressing : for a prompt.

detach-client cmd has a -a flag to detach all clients other than the attached client.

Layouts

even-horizontal C-b M-1 Spread out evenly across

even-vertical C-b M-2 Spread out evenly up and down

main-horizontal C-b M-3 One large pane at the top, the rest spread out evenly across

main-vertical C-b M-4 One large pane on the left, the rest spread out evenly up and down

tiled C-b M-5 Tiled in the same number of rows as columns

Advanced

tmux new -c/tmp start in working dir /tmp

Sharing

tmux -S /tmp/shared-socket new -s sharedSessionName
chgrp joint-group /tmp/shared-socket
# Other user
tmux -S /tmp/shared-socket attach -t sharedSessionName # -r for read only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment