114

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.

7
  • 3
    Well, it works as expected in X...don't know of a solution in quartz. Dec 25 '09 at 0:02
  • Bumping the question, because I don't want to ask it again.
    – dag729
    May 6 '10 at 20:05
  • 1
    bump too for me... would be great to have this
    – CharlesB
    Jun 24 '10 at 15:17
  • 3
    I 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. Aug 9 '10 at 19:01
  • 4
    You mean you want to give up your ability to replace the selected text with what's on the clipboard?
    – Spiff
    Sep 14 '10 at 17:40

11 Answers 11

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

1
  • 29
    And more problematic. It doesn't have the "highlight text to copy" feature.
    – Nifle
    May 11 '12 at 11:52
13

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.

1
  • 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
    Sep 22 '10 at 5:04
7

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

4
  • 2
    How do I copy-on-select across Terminal <-> Browser <-> Email? Feb 5 '12 at 21:39
  • As I said just for terminal to/from something nothing else
    – mmmmmm
    Feb 6 '12 at 11:50
  • Unfortunately iTerm feels much slower in responsiveness.
    – iltempo
    Sep 19 '12 at 8:57
  • 3
    For the record, iTerm2 (iTerm's successor) can be found here: iterm2.com
    – deizel
    Dec 21 '12 at 13:09
3

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
1
  • Perfect! Works on my Sierra (10.12.6). Sep 14 '17 at 7:40
1

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.

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.

1
  • This is an autohotkey script for macOS no?
    – William
    Oct 9 '18 at 23:45
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.

1
  • Brilliant !!!!!
    – mljrg
    May 19 at 18:42
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.

1

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.

1

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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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