Giter Site home page Giter Site logo

macpaste's Introduction

MacPaste - The Missing Mouse Paste Feature for MacOS

❗
The original code in this repo disappeared and I put up this one.
πŸ”₯
THIS CODE IS UNSUPPORTED!

This program simulates the middle mouse button copy/paste found in Unix/Linux X11 window managers: Once you highlight arbitrary text or visual elements, you can then middle click in the same or another window to paste the elements.

Note: Unlike X11, this program will alter your clipboard. Perhaps a future version could manage its own buffer like X11.

Installation

The script setup.sh takes care of most of the integration into MacOS.

  • If you have a three-button mouse, run ./setup.sh. You will have copy and paste right away.

  • If not (e.g. Trackpad, MagicMouse etc), run ./setup.sh -n. This will create the copy, but not the paste action. See below for ways to mimic the middle-click paste.

In detail, the script

  • compiles the C binary and puts it into $HOME/bin

  • creates a LaunchAgent plist file and puts it into $HOME/Library/LaunchAgents/

Then you have to open System Preferences β†’ Security & Privacy β†’ Privacy and add $HOME/bin/macpaste to allow the program to listen to system events.

If you want to test the installation, make sure your terminal is also listed in the Privacy list, and then run launchctl load $HOME/Library/LaunchAgents/local.macpaste.plist for the terminal.

Alternatively, log out and log in again.

The elusive middle button

One solution to work with stock Apple Trackpad and MagicMouse, which lack an explicit middle button, uses BetterTouchTool(BTT). If you don’t have it yet, it has a trial version but it’ll require a (rather cheap) license if you want to keep it for longer.

BTT has a much wider range of events and actions than the default MacOS, specifically it has a 1-Finger Middle Click for the MagicMouse, but not for the Trackpad. To have both behave in the same way, I chose 1-Finger Tap Middle (MagicMouse) and 1-Finger Tap Bottom Middle (Trackpad) as the triggers. You do you.

You can then add an action. The simplest is to use Send Keyboard Shortcut and set it to Apple-V, which uses the system clipboard to paste the item at the place of your cursor. Even nicer is the BTT custom clipboard. I’ve added two actions: Show Clipboard / Pasteboard History, followed by Paste specific items (configured with position 1 and Paste as Plain Text). This solves another long-standing issue I’ve had with MacOS, namely that it pastes with formatting by default, while I normally want only the text. This way, I can copy-paste plain text with the mouse and have the keyboard shortcut Apple-V for formatted text. Neat, right?

How?

This program assumes that the key combinations ⌘+C/⌘+V are mapped as copy and paste in your applications. If they are not, then this will not work, because the program simply posts the following events:

  1. ⌘+C down & up (copies your selected text or objects) whenever your left mouse button releases. This allows copying text that is drag highlighted, or double-clicked to highlight words or lines.

  2. Left Mouse Button down & up (position mouse cursor for paste insertion) on middle click.

  3. ⌘+V down & up after tiny delay following middle click.

If your mouse is left-handed, or you remapped the keystrokes, then just edit the C program and recompile.

macpaste's People

Contributors

pmelchior avatar lodestone avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.