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: tmux load-buffer puts a file's text in the tmux paste buffer

Tmux
~/tips/tip-tmux-load-buffer

tmux load-buffer ~/snippets/deploy.txt

Loads text from a file or a pipe so you can paste it anywhere.

save-buffer writes a tmux copy to a file. The reverse is just as handy: load text into a buffer, then paste it into any pane with Ctrl-b ].

tmux load-buffer ~/snippets/deploy.txt

The file’s content becomes the newest paste buffer. Go to the pane where you need it, press Ctrl-b ], and tmux types it in. I like that for long commands or config fragments you paste into remote shells, where your local clipboard can’t reach.

A dash reads from standard input, so any command output can go straight into a buffer:

git log -1 --format=%H | tmux load-buffer -

With -b you give the buffer a name, so it doesn’t get lost among the automatic buffer0, buffer1 list. Paste it later with paste-buffer -b name. And -w also sends the text to your terminal’s clipboard, where the terminal supports that.

A word of warning about pasting into a shell: if the text ends with a newline, the shell runs it the moment it arrives. Check what is in the buffer first with tmux show-buffer, especially for anything that deletes or restarts something.

Further reading: tmux manual page (OpenBSD)

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

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