#macos #clipboard #ffi

bin+lib pasteboard

CLI and Rust bindings for interacting with the macOS pasteboard

4 releases

0.1.3 May 14, 2021
0.1.2 Dec 25, 2020
0.1.1 Aug 7, 2019
0.1.0 Aug 7, 2019

#78 in #clipboard

Download history 41/week @ 2024-03-11 38/week @ 2024-03-18 28/week @ 2024-03-25 45/week @ 2024-04-01 37/week @ 2024-04-08 29/week @ 2024-04-15 34/week @ 2024-04-22 35/week @ 2024-04-29 18/week @ 2024-05-06 40/week @ 2024-05-13 32/week @ 2024-05-20 24/week @ 2024-05-27 25/week @ 2024-06-03 31/week @ 2024-06-10 24/week @ 2024-06-17 21/week @ 2024-06-24

105 downloads per month
Used in silicon

MIT license

8KB
153 lines

pasteboard

This crate provides both a CLI and Rust bindings for interacting with the macOS pasteboard.

CLI

At the command-line, pasteboard introduces a pb command which can be used like:

# Copy/paste string
pb copy /path/to/foo.txt
pb paste /path/to/bar.txt

# Copy image/sound
pb copy /path/to/foo.png -t image
pb copy /path/to/foo.mp3 -t sound

Rust bindings

From Rust, pasteboard exposes a Pasteboard enum with copy and paste methods which can be used like:

use pasteboard::Pasteboard;

fn main() {
    unsafe {
        // Copy/paste string
        Pasteboard::String.copy("/path/to/foo.txt");
        Pasteboard::String.paste("/path/to/bar.txt");

        // Copy image/sound
        Pasteboard::Image.copy("/path/to/foo.png");
        Pasteboard::Sound.copy("/path/to/foo.png");
    }
}

Notes

The pb command is able to copy files as strings, images, and sounds. However, it can only paste as strings currently, but more coverage is planned in future releases.

Dependencies

~3–4.5MB
~74K SLoC