astrand / xclip

Command line interface to the X11 clipboard
GNU General Public License v2.0
1.03k stars 73 forks source link

Add shortcuts for selection and version options in xclip #150

Open erikd234 opened 7 months ago

erikd234 commented 7 months ago

This commit introduces two new command-line shortcuts for the xclip utility. The '-s' shortcut has been added for the '--selection' option, allowing users to specify the X selection (primary, clipboard, secondary, or buffer-cut) more conveniently. Additionally, the '-v' shortcut for '--version' has been implemented, making it easier to check the version of xclip. The help message in xcprint.c has been updated accordingly to reflect these new shortcuts.

Also I added in the help command the short forms of the differetn selection targets (p, s, c , and b)

If you want me to update the to also use -s I can, manual testing works and the tests pass after changes.

hackerb9 commented 6 months ago

Thanks for the pull request, Erik!

I'm surprised -sel is not in the short help. Perhaps that is because xclip, like many X applications, allows any option to be abbreviated as long as it is unique. My tab completion on xclip -sTab shows

$ xclip -s
-selection  -sensitive  -silent

That means if xclip ever adds a -selfie options, for example, -sel would stop working and the documentation mentioning it would need to be changed.

While I like your proposal, I'm against using -s for selection, but only because it could be even better.

A while ago I made a pull request for a version which provided -c for clipboard, which is pretty much the only selection anyone frequently wants access to that is not the default. I do not think it got merged, though. (I also added -b for compatibility with xsel.)

By the way, editing the short help is not enough when changing command line options. The man page and the tab completion should also be updated.

erikd234 commented 6 months ago

Thanks, I thougth about the man page but I coudnlt find the man entry in the code base.

I see what your saying about -c. But -s fits with the other shortcuts (although -s could also be -silent)

At the very least we should add -sel to the help menu and man page. (and the info about c,s,p,b)