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!
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!
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.
You need to be running Xorg session but you can use xsel to manipulate the clipboard. Not sure if this works in Wayland.