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

Copy to clipboard #3

Closed
sindresorhus opened this issue Jul 10, 2018 · 7 comments
Closed

Copy to clipboard #3

sindresorhus opened this issue Jul 10, 2018 · 7 comments
Labels
feature-request New feature or request roadmap Likely to be implemented at some point work-in-progress Currently working on

Comments

@sindresorhus
Copy link

I use most of my Carbon images on Twitter to illustrate some code snippet. Would be useful if this tool could just put the image in the clipboard instead of writing to disk. For example, if I use the a --copy flag.

@mixn
Copy link
Owner

mixn commented Jul 10, 2018

Great idea! :) Note taken, will try working on this soon.

@mixn mixn added the feature-request New feature or request label Jul 10, 2018
@tsriram
Copy link

tsriram commented Jul 10, 2018

@mixn I'm happy to give this a go if you'd like, assuming you haven't started working on this already :)

@thib92
Copy link

thib92 commented Aug 14, 2018

@mixn Actually this issue relates to what I was talking about on #12.
I think a --copy flag would indeed be the best way to integrate it.
@tsriram have you started working on this?

@mixn mixn mentioned this issue Aug 14, 2018
@mixn mixn added the roadmap Likely to be implemented at some point label Sep 26, 2018
@mixn mixn added the work-in-progress Currently working on label Oct 14, 2018
@itaisteinherz
Copy link

I'm currently working on this, but it seems like a --copy flag wouldn't work because there currently isn't a usable cross-platform clipboard module which allows you to copy image.
I think the best solution for the moment being is enabling piping (see #12), and piping the CLI's output to an OS-specific clipboard application, such as pbpaste (or any other alternative) on *nix-based systems.

@mixn
Copy link
Owner

mixn commented Oct 16, 2018

@itaisteinherz I’ve already implemented this on https://github.com/mixn/carbon-now-cli/tree/feature/copy-3 and am currently resolving an issue on Linux.

It copies to clipboard flawlessly on macOS, does so on Linux too, but the reporter doesn’t exit without having to manually CTRL + C on Linux. It does copy the image though. Requires xclip on Linux and nircmd on Windows.

Haven’t managed to try it on Windows yet though…

And yeah, there isn’t a module for this and doing it cross-OS with images is basically hell. pbcopy doesn’t work with images either (at least to what I have found out researching — and trust me, I’ve researched this a lot). 😅

@mixn
Copy link
Owner

mixn commented Oct 16, 2018

@sindresorhus Maybe you could chime in on this since I am using your lovely execa to run the OS-specific scripts. 🙂 As mentioned in my comment above, it works flawlessly on macOS — it copies to clipboard and exits properly.

macos

On Linux, it copies properly, but doesn’t exit — it’s like the Promise is pending forever. You can see it doesn’t exit the Copying image to clipboard stage inside the Listr task.

linux

The relevant code for this can be found in this section of cli.js. Am I missing something here?

I’ve also noticed that it exits and copies properly on Linux when I use execa without await. It doesn’t copy to clipboard on macOS then though.

mixn added a commit that referenced this issue Oct 19, 2018
@mixn mixn closed this as completed in c060e3d Oct 19, 2018
@mixn
Copy link
Owner

mixn commented Oct 19, 2018

I just published v1.3.0 where this is available. 🙂🎉 npm i -g carbon-now-cli to update to that version.

✅ Cross-OS 😱
✅ Docs are here

Example of using it with a preset + pasting to Twitter:

copy-demo

Thank you all for chiming in! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request roadmap Likely to be implemented at some point work-in-progress Currently working on
Projects
None yet
Development

No branches or pull requests

5 participants