laktak / extrakto

extrakto for tmux - quickly select, copy/insert/complete text without a mouse
MIT License
878 stars 45 forks source link

Improve clipboard functionality #13

Closed ivanalejandro0 closed 6 years ago

ivanalejandro0 commented 7 years ago

We should extract the clipboard functionality into a separate script, which will allow us to have a better contained solution for clipboard handling. That will make it easier to have support for more platforms/apps.

I have a clipboard script that I often use that we could use as inspiration: https://gist.github.com/ivanalejandro0/fc918ddce0df882c7ad70b134da4a5b3

We can also get some ideas from tmux-yank's clipboard_copy_command function: https://github.com/tmux-plugins/tmux-yank/blob/master/scripts/helpers.sh#L116

laktak commented 7 years ago

I guess I should have read this before commenting on the PR ;)

It's a good idea as long as the user can override it. Also I would only be able to test this with Linux and macOS (and Bash on Windows but it has no real clipboard support).

ivanalejandro0 commented 7 years ago

Yes, totally... I just added an option to override the clipboard on #11. We could add a "supported platforms" or "supported clipboards" section on the docs and just point out that Windows isn't tested yet, hopefully we will get a Window user that's willing to test this for us.

laktak commented 7 years ago

Before I forget - it took me a while before I got xclip support working (there is a comment in the code as well) so we should keep xclip and pbcopy as they are.

I've added support for Bash on Windows - those are all I can test.

ivanalejandro0 commented 7 years ago

Yes, of course, I'm all for progressive enhancements and keeping what works is the way to go. My idea was meant to find a way to make the clipboard handling a bit better, not get rid of working parts.

john-kurkowski commented 6 years ago

extract the clipboard functionality into a separate script

How about a separate plugin? You mention tmux-yank, which already specializes in multiplatform clipboard handling. What if this plugin required tmux-yank?

This would couple the two plugins. But less orthogonal functionality for this plugin to maintain and diverge from the more widely used, more general tmux-yank.

laktak commented 6 years ago

I'd like to keep this dependency free. Also we already have three out of four supported by tmux.

john-kurkowski commented 6 years ago

What about copying in tmux-yank via a subtree then? Seems like a solid foundation that doesn't change that often anyway. You'd be able to update from and contribute back to the upstream.

Hardly the end of the world if you don't use it. Just trying to inch toward community solutions, vs. bespoke handling in this repo. This ticket shouldn't have to exist. 😉 Multiplatform clipboard handling should be off-the-shelf.

laktak commented 6 years ago

I'm with you that in an ideal world this ticket shouldn't exist, but tmux/linux required some special handling (see above) so I don't think there is any code that can be shared.

The implementation is tiny in any case, it's more about having someone to test it.

laktak commented 6 years ago

I'll close this ticket for now - I'm sure if someone is missing a specific implementation they will either open a PR or a new ticket.

ivanalejandro0 commented 6 years ago

There are a couple of good points here. It's nice to have this plugin to have as few dependencies as possible. And also it would be nice to somehow reuse solutions across the community.

Making this plugin depend on tmux-yank doesn't sound like a good idea to me, it provides a whole feature set besides 'just copy stuff'.

It would be nice if both tmux-yank and extrakto could use an extra dependency that is some sort of "multi platform, cover all corner cases, super slim, clipboard solution", that way developers can focus on solving the "clipboard" problem just once and many projects could benefit from it. I think that making that work would require some sort of dependency management on tpm. Sadly dependency management is not an easy thing to do, look al the time invested on different communities (python, golang, javascript, etc), and they all have their problems. Maybe this particular topic deserves a discussion on tpm's repo issues.

I guess you could install a tmux plugin dependency by requiring an extra plugin installation:

# dependency
set -g @plugin 'tmux-plugins/clipboard-lib'

# both these would use the clipboard-lib
set -g @plugin 'laktak/extrakto'
set -g @plugin 'tmux-plugins/tmux-yank'

For the time being I agree that closing this is a good idea, once this project has enough users and/or enough issues because of the clipboard that could be a good reason to improve on that direction. "If it works don't touch it", right? :)