How can I copy on select in the OS X Terminal like PuTTY does?

42

9

That PuTTY option to select and then right-click to paste is the best invention after the mouse. Is there any way to make Terminal in OS X do this? Hack the source code? Install something?

Is the source code for the OS X Terminal publicly available?

TraderJoeChicago

Posted 2009-10-29T15:31:41.883

Reputation: 763

Answers

9

Install SIMBL and then install TerminalCopyOnSelect.

  • At first, you should install SIMBL.
  • Download the zipped plugin file I mentioned above and expand it.
  • Copy the extracted file "TerminalCopyOnSelect.bundle" to the plugin directory which is located at ~/Library/Application Support/SIMBL/Plugins/
  • Terminate all processes of Terminal.app and restart it.

Justin

Posted 2009-10-29T15:31:41.883

Reputation:

As @Arjan said, Terminal can do this: Choose Edit > Paste Selection (or Shift-Comamnd-V) or Middle-Click, the latter of which I assume is what you meant by “right-click” in your original question. – Chris Page – 2012-01-05T08:51:29.077

This is cool. Already something, but what I really wanted was a:

CopyOnSelectAndPaste

Like putty! – TraderJoeChicago – 2010-01-07T17:53:23.157

42

In Terminal, select something and then within the same Terminal window do one of the following:

  • click and drag the selection (a bit; the mouse pointer will change), and release to paste (hit Esc while dragging to cancel)

  • or: paste using Shift-Command-V

  • or: paste using the middle mouse button

Arjan

Posted 2009-10-29T15:31:41.883

Reputation: 29 084

1Thanks for the middle mouse button tip! Feels like redemption! – justshams – 2018-03-07T15:36:19.250

This should have been the accepted answer ;-) – Jasper de Vries – 2018-06-01T09:37:07.123

10I use Cmd-Shift-V all the time! – Josh – 2009-10-29T18:16:00.930

7

iTerm, an alternative to Terminal, can do this.

KeithB

Posted 2009-10-29T15:31:41.883

Reputation: 8 506

And so can Terminal. Edit > Paste Selection or Middle-Click if you have a three (or more) button mouse. Or drag the text a few pixels and release. – Chris Page – 2012-01-05T08:45:26.430

6

iTerm 2 also has an option to copy text to the normal clipboard on selection:

You can remap the middle button to paste from the clipboard:

Like in Terminal, you can also use shift-command-V (Edit > Paste Special > Paste Selection) to paste the text that is selected elsewhere in the current window.

George

Posted 2009-10-29T15:31:41.883

Reputation: 1 496

5

To answer your 4 questions:

That putty option to select and then right-click to paste in the best invention after the mouse. Is there anyway to make the terminal do this?

No, you can however select the text you want and drag-n-drop your selection to the command prompt.

Hack the source code?

Probably can be done through reverse engineering, but why bother for something so trivial, and the fact that it's illegal :P

Install something?

iTerm as kbisset suggests.

Are the source code for the mac terminal public available?

No but iTerm's is

ricbax

Posted 2009-10-29T15:31:41.883

Reputation: 4 894

1Right click to paste is how it works in Putty (in windows) and I think maybe some Linux based terminal apps also. I haven't looked into it myself, but Karabiner should be able to "remap" right mouse button to middle mouse button (eg simulate a middle mouse button click) when the Terminal app has focus. – Herr Grumps – 2015-06-28T15:29:22.770

“No, you can however select the text you want and drag-n-drop…” The answer is “Yes”. You can Middle-Click to do the same thing as Edit > Paste Selection. “right-click to paste” is likely a typo; either Sergio meant “middle-click to paste” or he’s using a terminal application with a “Paste Selection” contextual menu command. – Chris Page – 2012-01-05T08:48:10.737

1Reverse engineering is not illegal in the United States. Not sure what country you're posting from, though. – samkass – 2012-09-11T17:58:26.843

3

You can launch an X11 server and use xterm. Everything is already in the box.

You can even type xterm& in Terminal.app, and X11 will automatically be launched.

mouviciel

Posted 2009-10-29T15:31:41.883

Reputation: 2 858

1

You can just select what ever you want with the mouse, then cmd+ right click the mouse, it will copy the selected text and paste it.

user6659625

Posted 2009-10-29T15:31:41.883

Reputation: 11

Nice. Command plus two-finger tap on the trackpad works too. – Arjan – 2018-06-24T12:30:52.997

1

You could also install TotalTerminal and enjoy hotkey access to a dropdown Quake-style terminal that has a copy-on-select setting too :-)

TotalTerminal augments the existing Terminal and doesn't replace it so I find it a nicer solution than installing and using another app :-)

Eno

Posted 2009-10-29T15:31:41.883

Reputation: 121

1

my workflow

for copy: cmd-shift-click - it copies full unix paths like putty

for paste: triple click trackpad which works like middle button of mouse on xwindow or right button in putty (requires: http://clement.beffa.org/labs/projects/middleclick/ )

wujek

Posted 2009-10-29T15:31:41.883

Reputation: 11

1

If you tried the accepted answer; the SIMBL TerminalCopyOnSelect approach but failed with a dialog showing:

Terminal 2.5 (v334) has not been tested with the plugin TerminalCopyOnSelect (null)(v0.1.0).
As a precaution, it has not been loaded. Please contact the plugin developer for further information.

It's because TerminalCopyOnSelect you downloaded applies only if Terminal.app bundle version is 237 - 240.

You can download and build it yourself from github .

git clone https://github.com/genki/terminalcopyonselect.git
cd terminalcopyonselect
open TerminalCopyOnSelect.xcodeproj
# edit Info.plist and set SIMBLTargetApplications's MaxBundleVersion to 400, which is enough for MacOSX Yosemite's Terminal.app
# hit build, and it will copy TerminalCopyOnSelect.bundle under it's proper place: ~/Library/Application Support/SIMBL/Plugins

mash

Posted 2009-10-29T15:31:41.883

Reputation: 111