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: wl-copy is the clipboard command for a Wayland desktop

Clipboard
~/tips/tip-linux-wl-copy-wayland-clipboard

uname -r | wl-copy

Pipe text to the clipboard and paste it back on Wayland.

Old clipboard tools were written for X11. On a Wayland session the native pair is wl-copy and wl-paste, from the wl-clipboard package.

sudo apt install wl-clipboard
uname -r | wl-copy
wl-paste > saved.txt

The first command after installing copies your kernel version, the second writes whatever is on the clipboard into a file.

A few options I’d keep in mind. -n on wl-copy leaves off the trailing newline, which you want for a token or a path:

pwd | wl-copy -n

wl-copy -c clears the clipboard, and -o serves just one paste and then quits, a nice habit for something sensitive:

wl-copy -o < secret.txt

With -p you work with the primary selection, the middle click one, and not the regular clipboard.

These talk to your Wayland compositor, so they fail from a text console or a bare SSH session. On wl-paste the -n flag means don’t add a newline, which is easy to mix up in scripts. And a one time paste may get eaten by a clipboard manager that grabs everything the moment it appears, leaving you with nothing to paste.

Further reading: wl-clipboard(1) manual page

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

More Clipboard tips xclip -selection clipboard < ~/.ssh/id_ed25519.pub dir | clip "+p paste from the clipboard Command-C copy on the Mac cat ~/.ssh/id_ed25519.pub | pbcopy All Clipboard tips (6) All topics

Link