67

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?

2
  • I suggest changing the accepted answer to the one with 4x the upvotes that doesn't require an install.
    – Noumenon
    Feb 9, 2021 at 13:01
  • '..best invention after mouse', plus one.
    – Timo
    Mar 29, 2022 at 13:53

12 Answers 12

12

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.
4
  • This is cool. Already something, but what I really wanted was a: CopyOnSelectAndPaste Like putty! Jan 7, 2010 at 17:53
  • 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
    Jan 5, 2012 at 8:51
  • 2
    Despite any plugin quality, installing terminal Third Party Plugins is a bad idea. May 21, 2021 at 21:48
  • @ChrisPage people want to copy from terminal by selecting, and then paste elsewhere. 'Paste selection' doesn't do that. Jun 30, 2023 at 18:52
54

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

5
  • 14
    I use Cmd-Shift-V all the time!
    – Josh
    Oct 29, 2009 at 18:16
  • 1
    Thanks for the middle mouse button tip! Feels like redemption!
    – shams.haq
    Mar 7, 2018 at 15:36
  • This should have been the accepted answer ;-) Jun 1, 2018 at 9:37
  • I was looking for this because wanted to enable "copy on select" however drag and drop option made me happy :p
    – biesior
    Sep 5, 2020 at 2:32
  • Or command right click with default mouse.
    – js2010
    Oct 19, 2023 at 17:21
10

iTerm, an alternative to Terminal, can do this.

1
  • 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
    Jan 5, 2012 at 8:45
7

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.

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

3
  • “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
    Jan 5, 2012 at 8:48
  • 1
    Reverse engineering is not illegal in the United States. Not sure what country you're posting from, though.
    – samkass
    Sep 11, 2012 at 17:58
  • 1
    Right 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. Jun 28, 2015 at 15:29
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.

2

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

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

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

1
  • Nice. Command plus two-finger tap on the trackpad works too.
    – Arjan
    Jun 24, 2018 at 12:30
0

iTerm2 has been doing this for ages. The thing is the default configuration assigns it to the middle button. If you have a 2-buttons mouse, you need to assign the paste action to a single click on the right button through iTerm -> Preferences -> Pointer -> Bindings -> Paste from Clipboard. In 2021, this is what the configuration looks like:

enter image description here

0

As far as I see, the only way to make the standard Mac OS Terminal behave like putty, is:

  • to Select&Copy: hold Command + Shift and double click the text/path you want to copy. It's automatically copied in an "alternative clipboard"
  • to paste(putty like): hold Command + Shift and Right-click. The text is automatically pasted for the "alternative clipboard".

Basically, on select&copy&paste it works just like Putty as long as you hold Command + Shift while doing it.

A word about the "alternative clipboard": it seems that if you copy a text using the described workaround, it can only be pasted using the same workaround, otherwise, by doing right-click->paste, it will paste from the standard clipboard

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .