niedzielski / cb

đź“‹ Universal command-line clipboard with automatic copy and paste detection. Eg, `cb|sort|cb`. The missing link between GUIs and CLIs!
The Unlicense
122 stars 6 forks source link
cli clipboard gui

đź“‹ cb

Universal command-line clipboard with automatic copy and paste detection. Eg, cb|sort|cb.

Purpose

cb is a clipboard for working between graphical and command-line interfaces (GUIs and CLIs). The clipboard is a surprisingly convenient integration between the two and doesn't use temporary files. cb automatically performs a copy or a paste based on the context.

Why you don't need cb

If any of the following are true, you do not need cb:

All cb provides is a consistent interface across operating systems. Any clipboard CLI will do. What's important is how you use the tool.

Usage

Supply standard input to copy:

$ echo abc|cb

Supply no input to paste:

$ cb
abc

Both copy and paste can appear in the same command:

$ curl "$(cb)"|cb

Contents on the clipboard can be used bidirectionally with other GUIs like graphical text editors or web browsers using the usual shortcut (control-c/v or command-c/v).

Installation

# Download the script to ~/bin/cb.
curl https://raw.githubusercontent.com/niedzielski/clipboard/main/cb -o ~/bin/cb &&

# Make the script executable.
chmod +x ~/bin/cb

cb also supports sourcing in Almquist-like shells like . cb or source ./cb.

The heart of cb is tiny so edit it however you like and discard the rest!

Dependencies

cb requires the following dependencies to be installed:

If in doubt, it's simplest to just try executing cb.

Troubleshooting

Is ~/bin in the PATH environment variable? grep --only-matching ~/bin <<< "$PATH" should report a match. If not, add it like PATH="$PATH":~/bin.

Examples

All of these examples appear trivial because copy-and-paste is ubiquitous. The intent is to demonstrate the understated usefulness of the system clipboard for CLI-GUI integration. You can work seamlessly across GUIs and CLIs with it.

License (Public Domain)

All code in this repository is public domain and may be used without limitation.