Code Monkey home page Code Monkey logo

cliptools's Introduction

Cliptools

A cross-platform CLI utility to manipulate the clipboard (aka pasteboard).

Supports Windows, MacOS, X11, and Wayland; powered by arboard (or rather a fork; bugs are my fault!)

Usage

To copy data from the terminal:

$ echo abc | cliptools copy

To paste the contents of the clipboard as HTML:

$ cliptools paste -t html
<p>Assertions are always checked in both debug and release builds, and cannot
be disabled. See <a href="https://doc.rust-lang.org/std/macro.debug_assert.html" title="debug_assert!">
<code>debug_assert!</code></a> for assertions that are not enabled in release builds by default.</p>

To view types supported by the current clipboard selection:

$ cliptools list-types
@public.tiff
html

Status

In development. Tested on MacOS, and I'm working on X11. There should be basic support for copy and paste (but no requesting specific types, etc) on Wayland and Windows.

Features

  • Print data from clipboard, optionally for a specific type (cliptools paste [-t format])
  • List types available for current contents of clipboard (clipboards list-types)
  • Change contents of clipboard (clipboard copy [-t format])

Content types

Clipboards generally support storing the same piece of information as different formats. For instance, if you copy HTML content from a browser, the browser might save two pieces of information in the clipboard, as part of one logical item:

  • An HTML item, containing the HTML markup for the selection, for pasting into a rich-text editor
  • A plain text item, containing the stripped text that was copied, for pasting into a terminal or plain text editor.

Each application can request the content type it prefers from the clipboard.

The specific way content-types are encoded depends on the platform, so cliptools provides standard aliases that work cross-platform: url, html, pdf, png, rtf, and text. These are accepted by the -t / --type argument. If you need to use another content type, you can use --system-type. In this case, you need to know how your platform encodes content types for the clipboard.

In some cases, such as if you use JSON input, cliptools will assume you are using standard aliases, unless you prefix the content type with an at sign (@). For instance, @image.tiff would give you TIFF contents on MacOS.

Return codes

  • 0 if everything went well
  • 1 if data was not found (e.g. no data for the requested format), or there was an error setting clipboard contents.
  • >1 for other errors

TODO

  • Support clipboard history. This is not available on all platforms, but is useful on those for which it is.
  • If using JSON input to fill in several content-types, there is no way to send in binary data (that's a JSON format limitation). There should be another input method for this use case.

cliptools's People

Contributors

mattx avatar

Watchers

 avatar  avatar

cliptools's Issues

Step-by-step guide?

Hello.

Do you have a step-by-step guide for someone who's new to the world of Rust and specifically MacOS?

Here's the results of my build:

User@C02FH2WPMD6N cliptools % cargo build
   Compiling core-graphics v0.22.3
error[E0432]: unresolved import `core_foundation::mach_port`
 --> /Users/User/.cargo/registry/src/github.com-1ecc6299db9ec823/core-graphics-0.22.3/src/event.rs:4:5
  |
4 |     mach_port::{CFMachPort, CFMachPortRef},
  |     ^^^^^^^^^ could not find `mach_port` in `core_foundation`

error[E0433]: failed to resolve: could not find `mach_port` in `core_foundation`
  --> /Users/User/.cargo/registry/src/github.com-1ecc6299db9ec823/core-graphics-0.22.3/src/sys.rs:32:44
   |
32 |     pub type CGEventTapRef = core_foundation::mach_port::CFMachPortRef;
   |                                               ^^^^^^^^^ could not find `mach_port` in `core_foundation`

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `core-graphics` due to 2 previous errors
User@C02FH2WPMD6N cliptools % rustc --explain E0432

Thanks!

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.