Copy/paste to the system clipboard from shell scripts

The clipboard kitten can be used to read or write to the system clipboard from the shell. It even works over SSH. Using it is as simple as:

echo hooray | kitty +kitten clipboard

All text received on stdin is copied to the clipboard.

To get text from the clipboard you have to enable reading of the clipboard in clipboard_control in kitty.conf. Once you do that, you can use:

kitty +kitten clipboard --get-clipboard

Source code for clipboard

The source code for this kitten is available on GitHub.

Command Line Interface

kitty +kitten clipboard [options]

Read or write to the system clipboard.

To set the clipboard text, pipe in the new text on stdin. Use the --get-clipboard option to output the current clipboard contents to stdout. Note that you must enable reading of clipboard in kitty.conf first.



Output the current contents of the clipboard to stdout. Note that this will not work if you have not enabled the option to allow reading the clipboard in kitty.conf Default: False


Use the primary selection rather than the clipboard on systems that support it, such as X11. Default: False


Wait till the copy to clipboard is complete before exiting. Useful if running the kitten in a dedicated, ephemeral window. Default: False