Skip to content

Instantly share code, notes, and snippets.

@hadisfr
Forked from ossdev-somewhere/xsel.el
Last active June 18, 2020 10:55
Show Gist options
  • Save hadisfr/eff8a0a7134aae7017cc9d3977dae869 to your computer and use it in GitHub Desktop.
Save hadisfr/eff8a0a7134aae7017cc9d3977dae869 to your computer and use it in GitHub Desktop.
Emacs-nox <-> X11 clipboard transfer
; You need "xsel" program.
(defun x-paste ()
"insert text on X11's clipboard to current buffer."
(interactive)
(insert (shell-command-to-string "xsel -b")))
(defun x-copy ()
"copy text on local kill-ring to X11's clipboard."
(interactive)
(copy-region-as-kill (point) (mark t))
(let ((process-connection-type nil))
(let ((proc (start-process "xsel" "*Messages*" "xsel" "-i" "-b")))
(process-send-string proc (car kill-ring))
(process-send-eof proc))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment