Bash script to copy any text to clipboard

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Hugh Neutron
Level 4
Level 4
Posts: 235
Joined: Wed Sep 25, 2019 3:52 pm

Bash script to copy any text to clipboard

Post by Hugh Neutron »

I'm working on fixing a bug in between Gimp 2.10 and QT programs that save clipboard data. This bugfix involves replacing the image clipboard data with text clipboard data. Is there a bash script that can automatically paste text in my clipboard?

Example:

$copyclipboard -a

Now "a" would be in my clipboard data, as opposed to the previous image stored.

I am aware I can press Alt F2 (run)+ *type "a" + Ctrl A + Ctrl C + Escape but if I had a bash script that I could set as a key binding it could make things much faster.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
always wanting to learn more about Linux. It saved me from the Windows 10 telemetry and SAAS nightmare.
User avatar
Hugh Neutron
Level 4
Level 4
Posts: 235
Joined: Wed Sep 25, 2019 3:52 pm

Re: Bash script to copy any text to clipboard

Post by Hugh Neutron »

Code: Select all

echo a | xclip -sel clip
solves the problem.
always wanting to learn more about Linux. It saved me from the Windows 10 telemetry and SAAS nightmare.
Locked

Return to “Scripts & Bash”