• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    C
  • License
    The Unlicense
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Global middle-mouse-click copy/paste for Mac OSX (C).

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/

Next, in your terminal run ~/bin/macpaste to run the program. This should prompt you to open System Preferences and give access to terminal.

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.

More Repositories

1

hyper-hacks

macOS Sierra hacks using some combination of Alfred 3, Karabiner-Elements, and Hammerspoon
Lua
145
star
2

kindle

No Kindle Highlights API? Take control with this CLI!
Ruby
90
star
3

marvel

Marvel Comics API for ruby
Ruby
13
star
4

vim-bird

A Free Vim Icon Replacement of a Bird
12
star
5

seticons

Set up custom icons for your macOS Applications without fear that an auto-update will scrap your changes
Ruby
9
star
6

overshare

URL Shortener, Web Server, and Code Snippets
CSS
9
star
7

critic-markup

CriticMarkup support for Atom.
CoffeeScript
3
star
8

ftl

OLD AND BUSTED - DON'T USE (FTL spins up and down AWS shit for whatever you need)
Ruby
3
star
9

vimfiles

My vim files
Vim Script
3
star
10

assert-agile

Like assert, but with Super Ninja Robot Magic
Ruby
2
star
11

arango_model

An ODM for ArangoDB in Crystal
Crystal
2
star
12

lodestone.github.com

my junk. yes I said it. my junk.
2
star
13

mediasort

Sort and tidy directories containing media (images, video)
Ruby
2
star
14

magneto-syntax

A delightfully magnetic color scheme for Atom Editor
CSS
2
star
15

sparks

magical static files
Ruby
1
star
16

uhura

An API to API translator
1
star
17

lookout

Crystal
1
star
18

Wayback.in

1
star
19

solenoid

Common monkey patches and useful things for me (a start)
1
star
20

knock-knock

HTTP requests at Google services using ClientLogin authentication in Ruby
Ruby
1
star
21

dicebag

A dice rolling simulation and textual graphing library
Ruby
1
star
22

best-alfred-pinboard-workflow

Go
1
star
23

Pterosaur-Color-Scheme

A color scheme for Sublime Text and Textmate
1
star
24

jenkins-lodestone

Make Jenkins CI Magnetic
JavaScript
1
star
25

ims

Send macOS iMessages via CLI
Ruby
1
star
26

rango

ArangoDB Ruby
Ruby
1
star
27

lodestone.vim

Lodestone's lodestone powered vim color scheme
Vim Script
1
star
28

daytripper

Fork of http://www.eyecon.ro/datepicker
JavaScript
1
star
29

lodestone-syntax

1
star
30

taskpaper

Ruby library for dealing with Taskpaper formatted plain text.
Ruby
1
star