Closed arkhan closed 3 years ago
yeah, that's doable, I need do some research on its code
Greetings, I'm trying to integrate greenclip and cliphist, but I still do not know how to do it
(list (s-split "\t" (shell-command-to-string "clipster -c -o -n 5 | awk '{gsub(/^ +| +$/,\"\")} {print \"\" $0 \"\"}'")))
I think that line can be used to obtain the elements of the clipboard
Pull request is welcomed.
I'm not sure how to use greepclip.
Looks you need run greeclip daemon
as clipboard server first. paste something, then run greenclip print
to list all items. I noticed line-feed
is changed into "\n" (one slash, one "n" character).
Check below code:
(autoload 'cliphist-flycut-read-items "cliphist-flycut" nil)
(autoload 'cliphist-parcellite-read-items "cliphist-parcellite" nil)
(autoload 'cliphist-clipit-read-items "cliphist-clipit" nil)
For example, you could use cliphist-clipit-read-items
as sample,
(split-string (shell-command-to-string "greenclip history") "[\r\n]+")
could be a good start.
Hi. I use greenclip
but am really new to Emacs (my elisp-fu nearly doesn't exist), so the best I can do right now is to provide some information.
As stated with examples in greenclip
's readme, an ideal way to retrieve an item from clipboard is with the command:
greenclip print | sed '/^$/d' | ???????????? | xargs -r -d'\n' -I '{}' greenclip print '{}'
where ????????? is our entry-selection program of choice. It would be nice if we can somehow "pipe" that into ivy
:) The last greenclip print
just re-copy the selected text and put it on top list again.
I made this with my little knowledge. It kinda works on its own. The problem is that when item
is big, and contain vague characters like $
, some shells (like fish-shell
) will not like it and error out.
(defun ivy-greenclip ()
"Select an item from clipboard history and re-copy it"
(interactive)
(let* ((history (split-string (shell-command-to-string "greenclip print | sed '/^$/d'") "[\r\n]+")))
(ivy-read "Copy item from entry: "
history
:action (lambda (item)
(shell-command (concat "greenclip print '" item "'"))))))
greenclip
replaces \n and \r with \xA0 before saving the item to the history file, so if we can do some regex replacing with item
, that last command will not be needed.
You can send me a pull request if you want my code merged.
@FollieHiyuki , try call-process
api. shell-command
is used when I was still not good at Emacs Lisp.
I don't think you need sed
. Emacs has its own API replace-regexp-in-string
.
Thanks. I have some more questions:
\xa0
in Emacs. I'm struggling with it :)cliphist
, since til now what I have done only touched x clipboard, and haven't done anything with Emacs kill ring at all.Thanks for the info. I will take a look. This might take a while, since I have to learn lisp along the way as well.
1ef5045 support greenclip (Chen Bin)
Thanks for your work, meanwhile I'm still fighting brackets :)
I tried it out and it works.
1 concern though: I tend to not have my clipboard clutter up, so I usually delete the clipboard history once in while. cliphist
currently saves cache when reading items. Adding a variable so that the users can control the caching behavior would be nice.
cliphist will synchronise cache with clipboard manager if it's not empty. So you don't need worry about clearing cache.
If you really need manually empty cache, eval (setq cliphist-items nil)
.
That was the last missing piece I needed. I think you can close the issue.
Hello, it's possible to add support for greenclipt https://github.com/erebe/greenclip thanks