IT lexicon › Infra & Ops › xclip and xsel

xclip and xsel

Infra & Ops På svenska → Updated: 2026-10-09
More info
Creator
Kim Saunders (xclip), Conrad Parker (xsel)
Released
Type
Command-line tool
License
GPL-2.0
Source
github.com/astrand/xclip

The two small programs that connect shell pipes to X selections, so that cmd | xclip becomes a clipboard entry and xsel -b pastes it back into the terminal.

Both appeared in 2001 and do the same job from opposite ends. xclip reads standard input and becomes the owner of a selection, PRIMARY unless told otherwise and CLIPBOARD with -selection clipboard; xclip -o prints it instead. xsel offers the same with shorter flags, -p, -s and -b for the three selections, and can also clear one or take it over. Because a selection in X is a promise rather than a buffer, the program has to stay alive: xclip therefore forks into the background and answers requests until someone else claims the selection.

That detail is what makes them everyday tools rather than curiosities. Vim, tmux and most shell setups have a line that pushes a selection through xclip, and a script that needs to put something on the user's clipboard has no other way. Under Wayland, wl-copy and wl-paste from wl-clipboard fill the same role, with the same background process for the same reason.

← Back to the lexicon