Skip to content

Instantly share code, notes, and snippets.

@andiogenes
Last active August 14, 2025 05:49
Show Gist options
  • Select an option

  • Save andiogenes/d96f9803c8f457ffe4b795c1b01710e9 to your computer and use it in GitHub Desktop.

Select an option

Save andiogenes/d96f9803c8f457ffe4b795c1b01710e9 to your computer and use it in GitHub Desktop.
Idea: Killing/yanking text from X clipboard
;; Exchange between `emacs -nw` and X clipboard
(defun x-select-text (text)
"Send TEXT to X11's clipboard."
(let ((process-connection-type nil))
(let ((proc (start-process "xsel" "*Messages*" "xsel" "-i" "-b")))
(process-send-string proc text)
(process-send-eof proc))))
(defun x-selection-value ()
"Get X11' clipboard string to insert it into in `kill-buffer`."
(shell-command-to-string "xsel -b"))
(when (not (display-graphic-p))
(setq-default
interprogram-cut-function #'x-select-text
interprogram-paste-function #'x-selection-value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment