Created
March 25, 2018 16:27
-
-
Save szobov/70890efabf895a8ce7f77c4cee7ec9b6 to your computer and use it in GitHub Desktop.
Copy/paste to xclip using emacs -nw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun copy-to-clipboard () | |
"Copies selection to x-clipboard." | |
(interactive) | |
(if (display-graphic-p) | |
(progn | |
(message "Yanked region to x-clipboard!") | |
(call-interactively 'clipboard-kill-ring-save) | |
) | |
(if (region-active-p) | |
(progn | |
(shell-command-on-region (region-beginning) (region-end) "xsel --clipboard --input") | |
(message "Yanked region to clipboard!") | |
(deactivate-mark)) | |
(message "No region active; can't yank to clipboard!"))) | |
) | |
(defun paste-from-clipboard () | |
"Pastes from x-clipboard." | |
(interactive) | |
(if (display-graphic-p) | |
(progn | |
(clipboard-yank) | |
(message "graphics active") | |
) | |
(insert (shell-command-to-string "xsel --clipboard --output")) | |
) | |
) | |
(evil-leader/set-key "o y" 'copy-to-clipboard) | |
(evil-leader/set-key "o p" 'paste-from-clipboard) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment