cliphist icon indicating copy to clipboard operation
cliphist copied to clipboard

Paste from clipboard manager into Emacs

  • Cliphist [[https://github.com/redguardtoo/cliphist/actions/workflows/test.yml][https://github.com/redguardtoo/cliphist/actions/workflows/test.yml/badge.svg]] [[http://melpa.org/#/cliphist][file:http://melpa.org/packages/cliphist-badge.svg]] [[http://stable.melpa.org/#/cliphist][file:http://stable.melpa.org/packages/cliphist-badge.svg]]

Paste from clipboard managers,

  • [[http://parcellite.sourceforge.net/][Parcellite]] on Linux
  • [[http://clipit.sourceforge.net/][ClipIt]] on Linux
  • [[https://github.com/erebe/greenclip]] on Linux
  • [[https://github.com/TermiT/Flycut][Flycut]] on macOS

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 [[https://github.com/abo-abo/swiper][Ivy]]. So now cliphist can work with any narrow&completion package (helm/ivy/consult/orderless/embark ...)

[[file:demo.png]]

  • Install Please install from [[http://melpa.org][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, #+begin_src elisp (require 'xclip) (setq cliphist-select-item-callback (lambda (num str) (xclip-set-selection 'clipboard str))) #+end_src ** Copy selected clipboard item into =kill-ring= If cliphist-cc-kill-ring is true, the selected/pasted string will be inserted into kill-ring. #+begin_src elisp (setq cliphist-cc-kill-ring t) #+end_src ** 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, #+begin_src elisp (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) #+end_src

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/]].