Skip to content

Instantly share code, notes, and snippets.

@v2e4lisp
Created January 20, 2015 09:14
Show Gist options
  • Save v2e4lisp/5c63aa1dfba0c6392cba to your computer and use it in GitHub Desktop.
Save v2e4lisp/5c63aa1dfba0c6392cba to your computer and use it in GitHub Desktop.
;; copy to clipboard from emacs in terminal
;;
;; if you use emacs in tmux you should enable pbcopy in tmux first
;; http://superuser.com/questions/231130/unable-to-use-pbcopy-while-in-tmux-session
;;
;; (require 'region-bindings-mode)
(defun pbcopy-region (start end)
(interactive "r")
(pbcopy (buffer-substring start end))
(set-mark-command t))
(defun pbcopy (string)
(let ((cmd (concat "echo " (shell-quote-argument string) " | pbcopy")))
(call-process-shell-command cmd nil t)))
(define-key region-bindings-mode-map (kbd "M-RET") 'pbcopy-region)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment