skip to Main Content

I’m using Debian “Buster” (version 10.3) with GNOME Desktop version 3.30.2.

Is there a way to clear the clipboard on demand, using Terminal command(s) only and without installing any clipboard manager?

Thank you for your time!

2

Answers


  1. You need to be running Xorg session but you can use xsel to manipulate the clipboard. Not sure if this works in Wayland.

    Login or Signup to reply.
  2. You can clear the X selection clipboard (the selection you can middle-click to paste) with xclip (install on Debian/Ubuntu-based systems with sudo apt install xclip).

    Once that’s installed, you can just run it:

    printf '' | xclip
    

    To remove the actual clipboard (which requires a key sequence to copy or paste), call it out explicitly:

    printf '' | xclip -selection clipboard
    

    You may need to first run export DISPLAY=:0 if you’re running this from a different session, and that assumes you’re running X11 on display zero. This should be automatically taken care of for you.

    These work by storing empty strings into the respective clipboards.

    There are clipboard managers like clipman that save your clipboard history. This does not interact with them.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search