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

Comments

Projects
None yet
5 participants
@sindresorhus

sindresorhus commented Jul 10, 2018

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

This comment has been minimized.

Owner

mixn commented Jul 10, 2018

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

@tsriram

This comment has been minimized.

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

This comment has been minimized.

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 referenced this issue Aug 14, 2018

Open

Enable piping #12

@mixn mixn added the roadmap label Sep 26, 2018

@itaisteinherz

This comment has been minimized.

itaisteinherz commented Oct 16, 2018

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

This comment has been minimized.

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

This comment has been minimized.

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 in c060e3d Oct 19, 2018

@mixn

This comment has been minimized.

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