Topics


Pages

  • pbcopy / pbpaste

    CLI tool for macOS to interact with clipboard data

  • xclip

    Command-line tool for X11 to interact with clipboard data

  • xsel

    CLI tool for Linux or Ubuntu to interact with clipboard data


Content

Features

Here’s a breakdown of what these tools can do:

  • View Clipboard Contents: Retrieve the current text or data stored in the clipboard.
  • Set Clipboard Contents: Copy text directly from the command line into the clipboard.
  • Simplify Scripting: Automate clipboard interactions within scripts using a shell command.

Which one to use

See also this StackOverflow answer for usage and shortcuts.

macOS

Using the pbcopy and pbpaste option is recommended.

Linux

You can use either xclip and xsel for similar results.

If you need to read data from files and set it as the clipboard content, xclip has the -in option while with xsel you need to pipe content.