This solution works reliably in any environment.

Insert below code into ~/.emacs . Run M-x paste-from-xclipboard to paste.

(defun my-gclip () "Get clipboard content." (cond ((eq system-type 'darwin) (with-output-to-string (with-current-buffer standard-output (call-process "/usr/bin/pbpaste" nil t nil "-Prefer" "txt")))) ((eq system-type 'cygwin) (with-output-to-string (with-current-buffer standard-output (call-process "getclip" nil t nil)))) ((memq system-type '(gnu gnu/linux gnu/kfreebsd)) (let* ((powershell-program (executable-find "powershell.exe"))) (cond (powershell-program ;; PowerLine adds extra white space character at the end of text (string-trim-right (with-output-to-string (with-current-buffer standard-output (call-process powershell-program nil t nil "-command" "Get-Clipboard"))))) (t (with-output-to-string (with-current-buffer standard-output (call-process "xsel" nil t nil "--clipboard" "--output"))))))))) (defun my-pclip (str-val) "Copy STR-VAL into clipboard." (cond ((eq system-type 'darwin) (with-temp-buffer (insert str-val) (call-process-region (point-min) (point-max) "/usr/bin/pbcopy"))) ((eq system-type 'cygwin) (with-temp-buffer (insert str-val) (call-process-region (point-min) (point-max) "putclip"))) ((memq system-type '(gnu gnu/linux gnu/kfreebsd)) (let* ((win64-clip-program (executable-find "clip.exe"))) (with-temp-buffer (insert str-val) (cond ;; Linux Subsystem on Windows 10 (win64-clip-program (call-process-region (point-min) (point-max) win64-clip-program)) (t (call-process-region (point-min) (point-max) "xsel" nil nil nil "--clipboard" "--input")))))))) (defun paste-from-x-clipboard(&optional n) "Paste string clipboard." (interactive "P") ;; paste after the cursor in evil normal state (when (and (functionp 'evil-normal-state-p) (functionp 'evil-move-cursor-back) (evil-normal-state-p) (not (eolp)) (not (eobp))) (forward-char)) (insert (my-gclip))) (add-hook 'minibuffer-setup-hook (lambda () (local-set-key (kbd "M-y") 'paste-from-xclipboard)))

My actual setup is more robust. See https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-clipboard.el for details.