Open maxandersen opened 8 months ago
Also, if freeze could simply output to stdout, on MacOS we could simply do ls | freeze | pbcopy
. That also allows piping to any other program, like a image compressor before copying.
Came here looking for clipboard output as well. But actually outputting to stdout
would this and many other use-cases and also be much simpler for yall to implement / maintain.
Folks can then pipe it into the clipboard app of their platform of choice (xcopy
for x11 linux, pbcopy
for mac os x, wl-copy
for linux wayland, etc.)
The problem I think at least in MacOS, from what I am working on freeze-code.nvim, is that pbcopy
unlike xclip
or wl-copy
can't copy images itself. But using osascript
to set the clipboard to read an image file and copy it it works fine. Same goes for Windows.
on run args
set the clipboard to (read (POSIX file (first item of args)) as JPEG picture)
end
-- or just png
on run args
set the clipboard to (read (POSIX file (first item of args)) as {«class PNGf»})
end
-- without args
set the clipboard to (read (POSIX file "<full-path-to-image>/image.png") as JPEG picture)
-- or just png
set the clipboard to (read (POSIX file "<full-path-to-image>/image.png") as {«class PNGf»})
Add-Type -AssemblyName System.Windows.Forms; [Windows.Forms.Clipboard]::SetImage($[System.Drawing.Image]::FromFile("$args[0]")))
# without args
Add-Type -AssemblyName System.Windows.Forms; [Windows.Forms.Clipboard]::SetImage($[System.Drawing.Image]::FromFile("<full-path-to-image>/image.png")))
If you want to do it natively
to the OS and executing a shell command.
In go
there is this repo for cross-platform clipboard which also allows you to use it from the terminal with gclip -copy -f image.png
as well as the API, haven't tried the API so I don't know in that regard.
freeze
and using any of the commands mentioned:
@maxandersen @ndom91 @Moulick @bashbunni
I made a PR (#97) using the previously mentioned cross-platform clipboard package if anyone want to test it out to see if solves this issue.
@AlejandroSuero sweet! This solves the clipboard problem.
~I still think that freeze
should also have an option to write to stdout
for other programs.~
nvm, it can write to stdout
apparently
https://github.com/charmbracelet/freeze?tab=readme-ov-file#output
Change the output file location, defaults to out.svg or stdout if piped. This value supports .svg, .png, .webp.
@Moulick When I tried on MacOS for example freeze Makefile | pbcopy
it will copy it but raw, without transformation.
That is what you are referring to right?
To be sure, if I need to change something in #97
@maxandersen @ndom91 @Moulick I added stdout
support on #102
awesome! looking forward for this to be in!
Is your feature request related to a problem? Please describe. I like to take snippet of code and paste image into chat or twitter directly,.
Describe the solution you'd like
freeze --clipboard mycode.java
or similar to then just be able to paste result without intermediate files