Shell commands to copy to clipboard

Time to take a visual copy!

The clipboard is an easy way to transfer data from the command line to other tools. Use your system’s “copy to clipboard” command to store a command’s output for pasting into other applications.

(See also my “paste from clipboard” post.)

On macOS, use pbcopy:

$ <command> | pbcopy

On Windows, use clip:

$ <command> | clip

On Linux with Wayland (most distributions), use wl-copy:

$ <command> | wl-copy

On Linux with X11 (typically older distributions), use xclip:

$ <command> | xclip

Fin

Copy happy!

—Adam


Read my book Boost Your Git DX to Git better.


Subscribe via RSS, Twitter, Mastodon, or email:

One summary email a week, no spam, I pinky promise.

Related posts: