Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added copy to clipboard functionality for windows,linux and mac #822

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

elliot40404
Copy link
Contributor

Added copy to clipboard functionality for Windows, Linux and mac using os/exec package. Please LMK if I need to change anything else. Also my formatter moved around 1 or 2 lines, I hope that won't be a problem. Thanks

@ryder203
Copy link

ryder203 commented Oct 6, 2024

Very nice and it's cool that you implemented it for MacOS and Linux too, but is it problematic if the used Linux distro does not have xclip installed? Would there be the need of some error output if xclip is not present? I'm not into Linux that much and maybe it's a stupid question.

@elliot40404
Copy link
Contributor Author

elliot40404 commented Oct 7, 2024

@ryder203 Your question is valid, xclip or for that matter any of the other utils used maybe not be present or deleted or just not accessible for any reason, in that case it will fail silently as the copy to clipboard functionality is not essential for croc to work. If it fails the line "code has been copied to clipboard" will not be printed to std err and if used with --debug the err will also show up in the logs.

@elliot40404
Copy link
Contributor Author

My bad. Now all tests should pass.

@schollz
Copy link
Owner

schollz commented Oct 7, 2024

thanks @elliot40404 !!! great pr.

@schollz schollz merged commit 0d48e34 into schollz:main Oct 7, 2024
2 checks passed
@ryder203
Copy link

ryder203 commented Oct 8, 2024

Awesome. Now using croc or croc tooth has some more flow with the next version on windows. A friend and I tested croc these days and I sent him a 20GB file in like 55 minutes and all worked like a charm. I really love it.

@bitraid
Copy link
Contributor

bitraid commented Oct 8, 2024

I'm sorry for commenting on an already merged PR, but I have a couple of suggestions:

  • On Windows: There is no need to run clip through cmd.
  • On Linux: Should support Wayland, by checking for example $XDG_SESSION_TYPE and using wl-copy instead of xclip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants