cheat.sheets:xsel
# xsel
# Command-line tool to access X clipboard and selection buffers
# Read from STDIN and save it to the clipboard; as if `Ctrl + C`.
echo 123 | xsel -ib
# A file's contents can also be provided to xsel(1x) via STDIN.
cat file | xsel -ib
# Send the clipboard's contents to STDOUT; as if `Ctrl + V`.
xsel -ob
# The contents of the clipboard can be saved to a file(s). Note that the use of
# `>` means that any existing file by the same name will be overwritten. Use
# `>>` to instead append the data to that file.
xsel -ob > file
# Clear the clipboard.
xsel -cb
# Send X11 primary selection to STDOUT, as if clicking mouse's middle button.
xsel -op
tldr:xsel
# xsel
# X11 selection and clipboard manipulation tool.
# More information: <https://manned.org/xsel>.
# Use a command's output as input of the clip[b]oard (equivalent to `Ctrl + C`):
echo 123 | xsel -ib
# Use the contents of a file as input of the clipboard:
cat path/to/file | xsel -ib
# Output the clipboard's contents into the terminal (equivalent to `Ctrl + V`):
xsel -ob
# Output the clipboard's contents into a file:
xsel -ob > path/to/file
# Clear the clipboard:
xsel -cb
# Output the X11 primary selection's contents into the terminal (equivalent to a mouse middle-click):
xsel -op
$
cheat.sh