Skip to content

redguardtoo/cliphist

Repository files navigation

Cliphist

https://github.com/redguardtoo/cliphist/actions/workflows/test.yml/badge.svg http://melpa.org/packages/cliphist-badge.svg http://stable.melpa.org/packages/cliphist-badge.svg

Paste from clipboard managers,

Users can add their own favorite clipboard managers on any OS easily. See the “Tips” section.

Please note since version 0.6 cliphist uses Emacs builtin API completing-read instead of ivy-read from Ivy. So now cliphist can work with any narrow&completion package (helm/ivy/consult/orderless/embark …)

demo.png

Install

Please install from melpa.

Usage

Make sure the clipboard manager is running.

If you use Flycut on macOS, set up “Preferences > General > Clippings” so its value is “Save After each clip”.

  • M-x cliphist-paste-item to paste item from history. C-u M-x cliphist-paste-item rectangle paste item
  • M-x cliphist-select-item to select item

Tips (OPTIONAL)

Customize cliphist-select-item

If you use “xclip.el” (https://elpa.gnu.org/packages/xclip.html), here is setup,

(require 'xclip)
(setq cliphist-select-item-callback
   (lambda (num str)
      (xclip-set-selection 'clipboard str)))

Copy selected clipboard item into kill-ring

If `cliphist-cc-kill-ring` is true, the selected/pasted string will be inserted into kill-ring.

(setq cliphist-cc-kill-ring t)

Add your own clipboard manager

Set cliphist-linux-clipboard-managers, cliphist-macos-clipboard-managers, cliphist-windows-clipboard-managers to insert/remove clipboard managers.

Here are steps to support a new clipboard manager named “myclip” on Linux.

Step 1, create a file “cliphist-myclip.el” with below content,

(require 'cliphist-sdk)
(defun cliphist-my-read-items ()
  (let (rlt
        (items '("clip1" "clip2")))
    (dolist (item items)
      (cliphist-sdk-add-item-to-cache rlt item))
    rlt))
(provide 'cliphist-myclip)

Step 2, add (push "myclip" cliphist-linux-clipboard-managers) into ~/.emacs.

Set up greenclip

Set cliphist-greenclip-program if greenclip program is not added into load-path and you use greenclip.

Bug Report

Check https://github.com/redguardtoo/cliphist.

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.