ethanholz / freeze.nvim

A Neovim plugin for freeze
MIT License
28 stars 5 forks source link

Add the ability to copy the produced image to the clipboard automatically #4

Closed cloudbridgeuy closed 7 months ago

cloudbridgeuy commented 7 months ago

This might be too much or too macOS oriented, but I'm using it and wanted to share it.

I changed the open option to an action one that takes two possible values: open or copy. If you pass the open, it will open the image as before, but if you set it to copy it will try to load the image to your clipboard using an osascript that must be available on the $PATH and named copy.

Here is what that script should look like:

#!/usr/bin/env bash

osascript -e{'on run{a}','set the clipboard to posix file a',end} "$(greadlink -f -- "$1")";

I got this from StackOverflow and I'm not entirely sure how it works, only that it does.

To simplify things, I added a warning message that gets printed if the copy command is not set.

This pattern also supports other ways of copying the images, so I prefer it.

I understand if these changes need to be clarified with the project.

freeze-copy-1_3-20240410133512

Pasting this image here to convince myself that it works :D

ethanholz commented 7 months ago

I do think this is out of scope for now. Ideally, I want this to be cross-platform. I am open to it in the future but right now I am not open to it.

ethanholz commented 7 months ago

I will open issue to track this and add this PR as a potential solution but as of right now I will be closing this.

cloudbridgeuy commented 7 months ago

Makes sense. Cheers!