When I have two buffers open side by side in as terminal (as shown in the screenshot), I cannot simply select text in a single buffer for copy and paste purpose. The selection will span across them, which is expected because it is how the terminal works.

enter image description here

My question is: is it possible to copy the text via Crtl-space and then put it in OSX's clip broad? (e.g. pipe the selected text to pbcopy?)


1 Answer 1


You could use shell-command-on-region to send the region's text to pbcopy.

(defun osx-copy-to-clipboard (beg end)
  (interactive "r")
  (message (if (zerop (shell-command-on-region beg end "pbcopy")) "copied" "copy failed")))

Not the answer you're looking for? Browse other questions tagged or ask your own question.