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: xsel -ib and xsel -ob move text between a Linux terminal and the clipboard

Linux
~/tips/tip-xsel-clipboard-pipe

cat config.yml | xsel -ib

Copy command output to the desktop clipboard and paste it back from the terminal.

Copying command output with the mouse is clumsy, especially a long one. On an X11 desktop I’d pipe it to the clipboard instead.

xsel works with three X selections. By default it uses PRIMARY, the one you fill by selecting text. The graphical copy and paste shortcuts use CLIPBOARD, so add -b:

cat config.yml | xsel -ib
xsel -ob > pasted.txt

-i reads standard input into the selection and -o writes the selection to standard output. -c clears it, which is handy after you copied a secret.

A caveat: xsel talks to an X server, so it needs a graphical session. Without a running X server it has nothing to talk to.

Further reading: xsel man page (Debian)

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

More Linux tips a2query -m rewrite renice -n 10 -p 4242 xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt flatpak uninstall --unused All Linux tips (261) All topics

Link