Skip to content
dozens edited this page Apr 14, 2024 · 4 revisions

tmux

I used to use screen. Now I use tmux.

Benefits include:

  1. A reasonable config file.
  2. Reasonable splits

See my tmux.conf for annotated configs

Saving pane contents

  1. :capture-pane -S -500 - yank 500 lines to a buffer
  2. :save-buffer filename.txt - write buffer contents to file

Copying/Pasting

NOTE: copying to system pasteboard is constantly broken everytime a new version of tmux comes out, and it is infuriating, and is seriously making me think of never updating tmux again, or going back to GNU screen

Use vi mode. In tmux.conf:

setw -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection

Then, <prefix> [ to enter copy mode. You can vim around, v to get visual, y to yank. Then, <prefix> p to put.

<prefix> # to view buffers you've yanked to.

When typing, <prefix> = followed by buffer number/letter n to paste from that buffer.

Redrawing

If you attach to a monitor, or resize your font or something, tmux might keep the size of your smaller laptop screen because it by default preserves the dimensions of the smallest screen across all sessions to which the window is attached. To fix this either-

  1. Detach, and tmux attach -d, or
  2. <prefix> D (that is, Prefix + Big D) and select the session with the smaller dimensions to detach.

Send Keys

usage:

tmux send-keys -t <target> '...'

example:

tmux send-keys -t 1 '(load "wumpus.cl")' c-m

src: https://minimul.com/increased-developer-productivity-with-tmux-part-5.html

Breaking panes

bind-key ! break-pane -d -n coolname
bind-key @ join-pane -s $.0

Resources

Clone this wiki locally