Skip to content

Instantly share code, notes, and snippets.

@misshie
Last active March 3, 2025 03:22
Show Gist options
  • Save misshie/41643d820f7d459c7f0f2256494a2a14 to your computer and use it in GitHub Desktop.
Save misshie/41643d820f7d459c7f0f2256494a2a14 to your computer and use it in GitHub Desktop.
Emacs init.el Configuration to Prevent Sudden Session Disconnection in Microsoft RDP
;; Explicitly copy/paste between the kill-ring and x-clipboard
;; using the xlip command
;; C-c y : yank from x-clipboard
;; C-c c : copy from kill-ring to x-clipboard
(setq x-select-enable-clipboard nil)
(setq x-select-enable-primary nil)
(defun yank-from-x-clipboard()
"Yank from X clipboard using xclip."
(interactive)
(insert (shell-command-to-string "xclip -selection clipboard -o")))
(global-set-key (kbd "C-c y") 'yank-from-x-clipboard)
(defun copy-to-x-clipboard (text &optional push)
"Copyto X clipboard using xclip."
(interactive (list (current-kill 0)))
(let ((process-connection-type nil))
(let ((proc (start-process "xclip" "*Messages*" "xclip" "-selection" "clipboard")))
(process-send-string proc text)
(process-send-eof proc))))
(global-set-key (kbd "C-c c") 'copy-to-x-clipboard)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment