Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting selected text in current window

Tags:

linux

x11

I'm trying to build a script that will add the currently selected text to the end of a file. So far it looks like cat selected_text >> quotes.txt.

Is there any way, either in command line or in C/C++ to get the currently selected text from the currently active window?

like image 288
pkinsky Avatar asked Mar 08 '26 22:03

pkinsky


1 Answers

Take a look at the xclip command

This command operates on X11 selections (the middle-click paste clipboard). It can be used to retrieve the last block of text that was selected using the mouse.

like image 167
Alex Jasmin Avatar answered Mar 12 '26 04:03

Alex Jasmin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!