copy to the clipboard from the terminal

Send a command's output or a file to the clipboard, and paste from it.

  • shell

Steps

  1. command | xclip -selection clipboard

    copy, on X11 (xclip)

  2. xclip -selection clipboard -o

    paste, on X11

  3. command | wl-copy

    copy, on Wayland (wl-clipboard)

  4. wl-paste

    paste, on Wayland

  5. command | pbcopy

    copy, on macOS

  6. pbpaste

    paste, on macOS

Notes

  • Over ssh, your terminal can take copies itself: lore's c key does it that way.

Commands used

  • xclip
  • wl-copy
  • pbcopy

Each has a page in lore: lore xclip opens it.