brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: set -g set-clipboard on lets tmux copy to your terminal's clipboard

Tmux
~/tips/tip-tmux-set-clipboard

set -g set-clipboard on

Lets tmux copy selected text to the clipboard of your terminal, even over SSH.

Copying in tmux puts text in a tmux buffer, which your desktop does not know about. Over SSH the gap gets wider, because the clipboard I want is on the machine in front of me.

tmux can ask the terminal to set its clipboard with an escape sequence. The option for it:

set -g set-clipboard on

The manual describes three values. With on, tmux accepts the escape sequence to create a buffer and also tries to set the terminal clipboard. With external, tmux sets the terminal clipboard but ignores applications that try to set tmux buffers. With off, it does neither.

Which one to pick depends on how much you trust what runs in your panes. external keeps a program in a pane from writing into your tmux buffers, while your own copy-mode selections still reach the system clipboard.

set -g set-clipboard external

The manual says tmux only attempts this when there is an Ms entry in the terminfo description of your terminal. For xterm it adds a note: the feature has to be enabled there with the resource disallowedWindowOps: 20,21,SetXprop, or by changing that property in the xterm menu.

The caveat is that terminals differ. Some ask for permission or have the feature switched off by default. If nothing lands on the clipboard after a copy, check the terminal’s settings first and tmux second.

Further reading: tmux manual (set-clipboard)

More Tmux tips tmux new -d -s report -x 200 -y 50 'top' tmux wait-for build-done set -g allow-passthrough on tmux kill-server Ctrl-b [ All Tmux tips (125) All topics

Link