Open AlejandroSuero opened 2 months ago
@AlejandroSuero Not working, I cloned your fork, checked out your branch and compiled. --copy
is not copying to the clipboard. Also make test
fails. I am on MacOS (14.5 (23F79))
❯ make test
go test ./...
? github.com/charmbracelet/freeze/font [no test files]
? github.com/charmbracelet/freeze/input [no test files]
? github.com/charmbracelet/freeze/svg [no test files]
? github.com/charmbracelet/freeze/test/input [no test files]
--- FAIL: TestFreezeCopy (0.04s)
freeze_test.go:81: clipboard is empty
FAIL
FAIL github.com/charmbracelet/freeze 2.748s
FAIL
make: *** [test] Error 1
@Moulick I am using the same version of MacOS and it builds correctly with go build
.
https://github.com/charmbracelet/freeze/assets/71392160/697f3f21-3fd6-481d-9b62-a56359f43c4b
./freeze --config user --lines 23,30 config.go --copy
after being built:
As for the test part, I committed a fix (eba42f9), apparently it was reading from the clipboard but not writing it, for example: If I have an image on the clipboard it will pass the test but it will fail otherwise.
make test
:
@AlejandroSuero now the test works, and the image generated by the make test appears in my clipboard. But running ./freeze --lines 23,30 config.go --copy
still writes the image to the disk rather than clipboard. Attaching the compiled binary from my laptop
After unzip freeze.zip
then ./freeze --execute "exa -l" --copy
I get this (recently powered up MacOS machine with nothing in the clipboard):
But running
./freeze --lines 23,30 config.go --copy
still writes the image to the disk rather than clipboard
With these, are you referring to the fact that it writes the output image as well as copying it to the clipboard?
When running ./freeze --lines 23,30 config.go --copy
with the downloaded freeze.zip I get the image freeze.png
as well as it being copied to the clipboard:
@AlejandroSuero not sure if there is something wrong with my machine but for me --copy
is writing the freeze.png
to disk and nothing to clipboard. Maybe we need someone else to try test
https://github.com/charmbracelet/freeze/assets/71392160/e10d653e-c3d0-4c5f-930e-b2a1ef195c39
@Moulick this is how it works for me just powering up the machine and having the clipboard empty.
With the changes in c57172d, It still passes the tests and works the same way manually for me.
Hey @AlejandroSuero, instead of introducing a new flag I wonder if we should simply allow --output clipboard
or --output copy
to copy to the clipboard, what do you think?
No opinions, but you could also introduce the option to print to stdout so you could freeze --output stdout | pbcopy
.
No opinions, but you could also introduce the option to print to stdout so you could
freeze --output stdout | pbcopy
.
In that case I would rather simply detect if stdout is a tty and send to stdout if it's not a tty.
freeze | pbcopy
@maaslalani the problem I contemplated when I thought about it in the first place was that if for example you want to write an output name like artichoke_example.png
and still you want to copy the image to the clipboard it won't be possible.
But I would like to hear your thoughts about that scenario.
@meowgorithm as for the stdout
@Moulick mentioned this in the issue linked to this PR:
--output clipboard
does sound like a better idea. I don't think anyone want to copy to clipboard and write to disk at the same time. Even on Android/iOS, the option when taking a screenshot is copy to clipboard and delete.pbcopy
does not handle putting images into the clipboard correctly. So freeze | pbcopy
cannot work.
freeze --output stdout
or detecting stdout tty should also be done, so we can use other programs (like image compression) in the workflow but probably in a separate PR.@Moulick I made some changes to work with librsvg
and for non-png formats.
I added some comments on how gclip does not seem to work as an image when copying non-png formats. I wrote an issue about it in their github to figure it out.
As @maaslalani suggested, I made the changes so the user can freeze cut.go --output clipboard
.
With these changes (9a169d5, 01d684a), the comment https://github.com/charmbracelet/freeze/pull/97#issuecomment-2162657455 is worked around so it will always use .png
format to copy the image.
Changes made
With this addition the user can choose in interactive mode, or with the flag
--copy
, to copy the created image to their system's clipboard. This was achieved with the cross-platform clipboard package by golang-design.Tests
make test
:./freeze --config user --lines 23,30 config.go --copy
to get this image:Closes #58.