copy to the clipboard from the terminal
Send a command's output or a file to the clipboard, and paste from it.
Steps
-
command | xclip -selection clipboardcopy, on X11 (xclip)
-
xclip -selection clipboard -opaste, on X11
-
command | wl-copycopy, on Wayland (wl-clipboard)
-
wl-pastepaste, on Wayland
-
command | pbcopycopy, on macOS
-
pbpastepaste, on macOS
Notes
- Over ssh, your terminal can take copies itself: lore's c key does it that way.
Commands used
xclipwl-copypbcopy
Each has a page in lore: lore xclip opens it.
Related recipes
- add a folder to the pathLet the shell find programs in a folder, for good, and reload the settings without logging out.
- add to the end of a fileAdd lines to a file without replacing it, also to a file only root can write.
- argument list too long"Argument list too long" from rm, cp or mv: too many files for one command line. Hand them over in batches.
- ask for input in a scriptAsk yes or no, read a password without showing it, or wait for an answer with a time limit.