Jump to content
Sign in to follow this  
effe

Remove several clipboard history items by criteria?

Recommended Posts

Is it possible to remove several clipboard history items at once? I would for example like to be able to occasionally, on demand, be able to remove all clipboard history text items < 3 characters long. I know I can fn-delete individual items in the list, but I'd like to be able to perhaps activate a workflow to prune the clipboard history list en masse. Any ideas? Possible?

Share this post


Link to post

@effe While this isn't possible natively in Alfred, the clipboard database is actually just an SQLite DB, so with a bit of scripting, you should be able to quite easily manipulate the database. You'll find the clipboard db in the following location:

 

~/Library/Application\ Support/Alfred\ 3/Databases/clipboard.alfdb

 

The database has one table (clipboard) with the following columns:

 

clipboard(item, ts decimal, app, apppath, dataType integer, dataHash);

 

The text data is stored in the "item" column, and you'd probably want to only touch items with dataType = 0 as this is text items. Other items have external dependencies outside the database, such as images.

 

Also worth adding that you fettle with this at your own (low) risk. The worst thing that could happen is you lose your history and have to start again.

 

Cheers,

Andrew

 

Share this post


Link to post

Thank you. Apologies for not following up. I did end up just making a simple script that I run periodically to clear out short history items:

 

#!/usr/bin/env bash

threshold=3;

sqlite3 "${HOME}/Library/Application Support/Alfred 3/Databases/clipboard.alfdb" <<STATEMENT
  DELETE FROM clipboard
  WHERE datatype = 0 AND
        LENGTH(TRIM(item)) <= $threshold;
STATEMENT

echo "text clipboard items with length <= $threshold removed from Alfred history"

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  
×
×
  • Create New...