Coder Social home page Coder Social logo

Greenclip Support about cliphist HOT 13 CLOSED

redguardtoo avatar redguardtoo commented on June 11, 2024
Greenclip Support

from cliphist.

Comments (13)

redguardtoo avatar redguardtoo commented on June 11, 2024

yeah, that's doable, I need do some research on its code

from cliphist.

arkhan avatar arkhan commented on June 11, 2024

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

from cliphist.

redguardtoo avatar redguardtoo commented on June 11, 2024

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.



from cliphist.

FollieHiyuki avatar FollieHiyuki commented on June 11, 2024

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.

from cliphist.

FollieHiyuki avatar FollieHiyuki commented on June 11, 2024

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.

from cliphist.

redguardtoo avatar redguardtoo commented on June 11, 2024

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.

from cliphist.

FollieHiyuki avatar FollieHiyuki commented on June 11, 2024

Thanks. I have some more questions:

  • How can I regexp-replace the character \xa0 in Emacs. I'm struggling with it :)
  • And can you provide some guideline on how to integrate this into cliphist, since til now what I have done only touched x clipboard, and haven't done anything with Emacs kill ring at all.

from cliphist.

redguardtoo avatar redguardtoo commented on June 11, 2024

https://www.gnu.org/software/emacs/manual/html_node/elisp/Non_002dASCII-in-Strings.html#Non_002dASCII-in-Strings

https://github.com/redguardtoo/cliphist/blob/master/cliphist.el#L131

from cliphist.

FollieHiyuki avatar FollieHiyuki commented on June 11, 2024

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.

from cliphist.

redguardtoo avatar redguardtoo commented on June 11, 2024

1ef5045 support greenclip (Chen Bin)

from cliphist.

FollieHiyuki avatar FollieHiyuki commented on June 11, 2024

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.

from cliphist.

redguardtoo avatar redguardtoo commented on June 11, 2024

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).

from cliphist.

FollieHiyuki avatar FollieHiyuki commented on June 11, 2024

That was the last missing piece I needed.
I think you can close the issue.

from cliphist.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.