How to copy text to the clipboard when using Wayland?

bugaevc's wl-clipboard are copy/paste utilities for Wayland:

This project implements two little Wayland clipboard utilities, wl-copy and wl-paste, that let you easily copy data between the clipboard and Unix pipes, sockets, files and so on.

Usage is as simple as:

# copy a simple text message
$ wl-copy Hello world!

# copy the list of files in Downloads
$ ls ~/Downloads | wl-copy

# copy an image file
$ wl-copy < ~/Pictures/photo.png

# paste to a file
$ wl-paste > clipboard.txt

# grep each pasted word in file source.c
$ for word in $(wl-paste); do grep $word source.c; done

# copy the previous command
$ wl-copy "!!"

# replace the current selection with the list of types it's offered in
$ wl-paste --list-types | wl-copy

Although wl-copy and wl-paste are particularly optimized for plain text and other textual content formats, they fully support content of arbitrary MIME types. wl-copy automatically infers the type of the copied content by running xdg-mime(1) on it. wl-paste tries its best to pick a type to paste based on the list of offered MIME types and the extension of the file it's pasting into. If you're not satisfied with the type they pick or don't want to rely on this implicit type inference, you can explicitly specify the type to use with the --type option.

For all common linux-distributions the package-name is wl-clipboard, so use the command that suits yours (if not already installed):

sudo apt install wl-clipboard  # Debian
sudo yam install wl-clipboard  # Fedora
sudo pacman -S wl-clipboard    # Arch linux

wclip is a clipboard tool for Wayland that is very similar to xclip.

Usage is as follows:

$ wclip i < my_text_file

$ wclip o contents of my text file $

Disclaimer: I am the author.