Copy-on-select, paste-on-middle-click on Mac OS X?

98

20

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?

command+C, command+V is a little annoying.

nibot

Posted 2009-12-24T22:28:46.993

Reputation: 1 522

Bumping the question, because I don't want to ask it again. – dag729 – 2010-05-06T20:05:24.177

1bump too for me... would be great to have this – CharlesB – 2010-06-24T15:17:19.900

1Another evidence linux is superior to mac os. – Blessed Geek – 2017-03-02T01:32:42.617

2I just wanted to ask the same question. I recently started to work on MacOS X at my workplace and I am long time Linux user, this is one hell of a Linux feature I am missing on MacOS. – Patkos Csaba – 2010-08-09T19:01:22.217

4You mean you want to give up your ability to replace the selected text with what's on the clipboard? – Spiff – 2010-09-14T17:40:09.803

As an aside: I don't think it is copied to the clipboard, but simply does not use the clipboard at all? – Arjan – 2011-03-26T12:09:16.150

– Ray Baxter – 2011-07-13T19:11:32.420

3Well, it works as expected in X...don't know of a solution in quartz. – dmckee --- ex-moderator kitten – 2009-12-25T00:02:31.610

Answers

16

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).

jstarek

Posted 2009-12-24T22:28:46.993

Reputation: 928

26And more problematic. It doesn't have the "highlight text to copy" feature. – Nifle – 2012-05-11T11:52:06.797

11

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.

drag and drop

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.

Arjan

Posted 2009-12-24T22:28:46.993

Reputation: 29 084

Actually copy/drag text works great for me in any editor target (ie, Terminal, BBEdit, text input box on this page, etc)... you can combine a drag with Exposé and CMD-tab. Also, if you want to "copy to clipboard", you can just drag to desktop and it will create a text clipping that you can then drag to other locations repeatedly (it's like a visual clipboard in a way). – r00fus – 2010-09-22T05:04:46.583

6

If you just need it for Terminal then you can install iTerm2 which is a terminal which has the X windows cut and paste.

user151019

Posted 2009-12-24T22:28:46.993

Reputation: 5 312

2How do I copy-on-select across Terminal <-> Browser <-> Email? – Aleksandr Levchuk – 2012-02-05T21:39:35.833

As I said just for terminal to/from something nothing else – user151019 – 2012-02-06T11:50:43.103

Unfortunately iTerm feels much slower in responsiveness. – iltempo – 2012-09-19T08:57:45.567

2

For the record, iTerm2 (iTerm's successor) can be found here: http://www.iterm2.com/

– deizel – 2012-12-21T13:09:41.067

2

I just tried Terminal (OS X El Capitan, Version 10.11.5). The process I used is this:

  1. Highlight text
  2. Holding 1 finger, drag a bit up (the highlighted text moves and green '+' appears)
  3. Release and the highlighted text appears in the command line

Vladimir Lukin

Posted 2009-12-24T22:28:46.993

Reputation: 21

Perfect! Works on my Sierra (10.12.6). – Bjarte Brandt – 2017-09-14T07:40:16.220

1

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.

ralome

Posted 2009-12-24T22:28:46.993

Reputation: 19

1

I am using BetterTouchTool and have configured it to emulate a middle mouse button in Terminal application on three finger click.

Michal

Posted 2009-12-24T22:28:46.993

Reputation: 11

1

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.

tumchaaditya

Posted 2009-12-24T22:28:46.993

Reputation: 3 624

This is an autohotkey script for macOS no? – William – 2018-10-09T23:45:39.327

1

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.

iltempo

Posted 2009-12-24T22:28:46.993

Reputation: 147

0

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.

avirk

Posted 2009-12-24T22:28:46.993

Reputation: 15 151

0

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.

Lawrence Velázquez

Posted 2009-12-24T22:28:46.993

Reputation: 929

-1

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

Theo Belk

Posted 2009-12-24T22:28:46.993

Reputation: 610