Clipboard icon indicating copy to clipboard operation
Clipboard copied to clipboard

Allow direct output of text or raw data, rather than needing to pipe output through cat

Open map588 opened this issue 1 year ago • 3 comments

I am trying to use cb as a custom clipboard for neovim, and because of all the output formatting, my buffers get full of non-ascii characters of the output cli when that specific clipboard is empty, and preferably I could either use 'paste' or 'show' to just, put out the data with no frills.

Its tedious to try and make shell commands using lua (at least for me) that pipe output to something like cat, and it feels odd to me this feature does not already exist.

That feature being, just vomit out the raw contents of that clipboard (if its not a file or directory, and it exists), and do nothing otherwise. I am annoyed that I am reliant on 'echo' and 'cat' to move data in and out of clipboards from stdin and stdout, I guess. That seems like a trivial thing but its been the bane of my little project.

Yes, I set the environment variables and double checked. Its probably a Lua skill issue, and its certainly possibly in the current state to accomplish what I am trying to do, but it stood out to me as odd that trying to just grug-brain text in and out of a clipboard was not a trivial thing. All the other features are awesome and for CLI use, its nice to see, but I wish there were an actual silent flag.

I looked through the code, and I am not C++ certified enough to understand how it fits together, I do not think I could submit a pull request.

map588 avatar Jan 25 '25 11:01 map588

I could probably add a --raw flag to disable everything except the raw content. Would that be a good solution for you?

Slackadays avatar Jan 25 '25 17:01 Slackadays

Yes, that would be perfect. Would it be possible to have --raw for copy and paste? The reason being is I need to put "'s around everything coming from neovim for it to just except text and not try to find a file that wouldn't exist. So with the raw flag it might behave like:

cb copy 123
cb paste
output>>123

and so on for any other clipboard, like cb cp25 123; cb p25 => 123

Thank you for the quick response!

map588 avatar Jan 25 '25 18:01 map588

I was planning on making the neovim module basically:

index = 1
cb copy(index) [whatever was put in the neovim clipboard buffer]

-- (then asynchronously)

if cb paste_history == null
   cb load index  _nvim-history
else
   cb paste(index) | cb add_nvim-history

cb add_nvim-history "\n"

(++index)%(max+1)

Then I could use something like fzf-tmux to select from all the history of nvim copies, which would be pretty cool. All of the cb commands in the example would use the flag --raw except for load and add I think.

map588 avatar Jan 25 '25 19:01 map588