Is there a way to give OS X the usual X-windows behavior where selecting text in any application automatically copies it to the clipboard, and the middle mouse button automatically pastes it?
12 Answers
This has already been discussed (and answered) on apple.stackexchange.com. The accepted answer in that discussion was to use Better Touch Tool.
However, all those solutions that suggest using some tool to map a mouse click to Cmd-V do not completely mimic the behaviour of X, where you can have different content in the mouse-controlled buffer and the keyboard-controlled buffer (i.e., you can paste two different strings depending on whether you middle-click or press CTRL-V).
Just for the archives: what you want does actually work in Terminal†, but only in the very same Terminal window:
Select some text (and release the mouse button), and use the middle mouse button to paste.
Alternatively, when using the trackpad or a two-button mouse: after selecting, click and drag the selection just a bit; you'll see the pointer change. Now, when you let go of the button, the selected text is pasted at your cursor. Hitting Esc while dragging cancels.

† Of course, Terminal is just one out of many programs. But for me, it is the only place I actually want this behaviour, if only because of Spiff's comment about being able to replace (mouse) selected text with what's on the clipboard.
I just tried Terminal (OS X El Capitan, Version 10.11.5). The process I used is this:
- Highlight text
- Holding 1 finger, drag a bit up (the highlighted text moves and green '+' appears)
- Release and the highlighted text appears in the command line
- 2,352
- 2
- 19
- 28
- 141
I don't have a mac so I can't check this out and the content was too long for just a comment so I'm posting it as an answer. Maybe it will prove helpful to others.
Solution1:
Go to X11 preferences - highlight "emulate 3 button mouse".
Now middle click = option+click.
Highlight/paste will work just like in Linux.
Solution2:
Another way is to install the better touch tool, this allows you to assign your own commands to different mouse/touchpad gestures.
- 1 finger right tap = cmd c (copy) and
- 2 finger tap = cmd v (paste)
It is one step more than the highlight = copy, but still preferable over the keyboard shortcuts.
From the macworld hintforums.
I know this isn't exactly the same, but if you select text and right click on it, you do have the option to copy. Once something is on the pasteboard, a right click can paste as well.
I fooled around with my Logitech multi-button mega mouse and couldn't make anything exactly like what you describe, even though one of the options is a "middle click" button.
Theo
- 650
As a long time linux user I've been desperatly searching for such functionality in osx. Mark is right - iTerm is the answer plus some settings in the X11 Preferences. Visit here for more info.
DISCLAIMER: I have not tested this because I don't have a mac. But, the content was too large to post as a comment. So, I am posting it as an answer instead.
I am windows user and have implemented exact same function in windows using a script written for a program called Autohotkey.
Now, as per this question, IronAHK runs AHK scripts on Mac.
Here's the one I am using for windows (Ofcourse, you would have to tweak it a lot to make it work):
cos_mousedrag_treshold := 20 ; pixels
#IfWinNotActive ahk_class ConsoleWindowClass
~lButton::
MouseGetPos, cos_mousedrag_x, cos_mousedrag_y
keywait lbutton
mousegetpos, cos_mousedrag_x2, cos_mousedrag_y2
if (abs(cos_mousedrag_x2 - cos_mousedrag_x) > cos_mousedrag_treshold
or abs(cos_mousedrag_y2 - cos_mousedrag_y) > cos_mousedrag_treshold)
{
wingetclass cos_class, A
if (cos_class == "Emacs")
sendinput !w
else
sendinput ^c
}
return
~mbutton::
WinGetClass cos_class, A
if (cos_class == "Emacs")
SendInput ^y
else
SendInput ^v
return
#IfWinNotActive
;; clipx
^mbutton::
sendinput ^+{insert}
return
Script credit goes to this post. Try experimenting and comment if you get it to work. I'll try to help as much as possible.
Meanwhile, have a look at this as well. But, I don't think it is advanced enough for the function you desire.
- 3,752
- 5
- 41
- 58
I didn't find a native way either. After trying different things I ended up using TotalTerminal.
It adds some additional functionality to the terminal app. Besides copy-on-select you can set a global key to bring up the terminal whenever you like.
If you want Linux copy with mouse selection, install HammerSpoon (brew install hammerspoon) , add privileges in settings System Preferences → Security & Privacy → Accessibility and execute commands in terminal mkdir -p ~/.hammerspoon touch ~/.hammerspoon/init.lua and in init.lua configure copy with mouse selection.
- 111
You might try fiddling with your mouse settings to see if the driver lets you assign the paste function to middle-click. If it doesn't, try looking into USB Overdrive.
As for copy-on-select, I am unaware of any software that gives you this functionality, and judging from what I can find on Google, none probably exists.
