Site logo image
[Home Page]

[RSS Feeds]

[IRC Server]

Return to Misc. Software Guides

Print Page mail icon

How to restore plain text clipboard functionality with xclip on Linux desktops

  With xclip, you can restore the plain text functionality in copy / paste behavior of the desktop clipboard. This will effectively remove any text formatting, images, embedded URL links, etc.

You may need to install the xclip package first since it's not a typical default package for most Linux distributions.

sudo apt install xclip

After completing the xclip install, create a shell script that is available in your user $PATH environment (i.e. in ~/bin or ~/.local/bin). Don't forget to apply the execution bit to the file so that you're able to run it.

chmod +x

The contents of the shell script should include the following:

xclip -o | xclip -selection clipboard

Instead, if you would prefer to eliminate beginning and trailing white spaces, you can use the following.

xclip -o | awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); print }' | sed -z 's/\(.*\)\n$/\1/' | xclip -selection clipboard

Now open your keyboard shortcut settings and create a custom shortcut that will launch the script. I highly recommend using something other than “Ctrl-C” since overriding this command could affect the functionality of other programs (i.e. VIM or KeePassXC.) Use Ctrl-Shift-C instead.

[Return to top]

Last modified date: 2022-07-11

nationality icon

Copyright © 2020-2022 All Rights Reserved.