Emacs as an X Clipboard Manager, take 2

I am no longer using any of the solutions from my first Emacs as an X Clipboard Manager post. I am now using an automatic, event-driven solution that is just a simple shell script. This makes the Emacs kill-ring an X clipboard manager without requiring the user to run some yank operation to pull content from the X clipboard. The shell script depends on clipnotify.


id=$(id -u)

while clipnotify; do
  if pgrep -q -u "$id" -f 'emacs --daemon'; then
    emacsclient -n -e "(current-kill 0)"

If you want to save the kill ring between Emacs sessions, add kill-ring to savehist-additional-variables.

If your terminal emulator supports the OSC 52 ANSI escape sequence, then terminal applications (running on remote hosts) can copy to the X clipboard (without X forwarding) as well.

Posted 2021-05-10 16:40 | Comments

Recent posts

Monthly Archives

Yearly Archives