Clipboard Filtering

post by jefftk (jkaufman) · 2024-04-14T20:50:02.256Z · LW · GW · 1 comments

Contents

1 comment

Here's a pattern I find pretty useful:

pbpaste | some_command | pbcopy

For example:

The way this works is that pbpaste reads from the clipboard as plain text, the intermediate command(s) transform the text, and the pbcopy sends it back to the clipboard.

While these are the Mac commands it should be similar elsewhere. For example, on Linux I'd use xsel, though that does require paying attention to whether you want PRIMARY (xsel) or CLIPBOARD (xsel -b).

Comment via: facebook, mastodon

1 comments

Comments sorted by top scores.

comment by gilch · 2024-05-07T00:03:39.649Z · LW(p) · GW(p)

One can also use Vim to edit clipboard text. I've experimented with a few ways. Here's a published example of how it could be done (from someone else). Adding a keyboard shortcut makes it faster when you're not already in a terminal. You can edit (e.g.) web text boxes with Vim this way, although active JavaScript doesn't always react to a paste the same way as typing. Depends on the page.