Searching All Your Clipboard History EVER Via Alfred In The Terminal
18 June 2021
.
We have written in the past about auto suggestions as you type using your shell history. A recent tip from @mrw led us to learn that Alfred actually stores ALL of your clipboard history in a file. So if you’re an Alfred user, you can access your clipboard history data in a sqlite table. Leveraging that you can actually search your clipboard history in the terminal by connecting to that sqlite database and querying against it. Let’s check it out!
Inspiration
As mentioned in the auto suggestion post we leverage zsh-histdb their to be able to query from a sqlite table. We use similar logic to pull in the Alfred sqlite file and query that.
Let’s Get To The Code
The first thing we need to do is to load in the sqlite file, so we set that to a variable to reference later:
Next we need to make a function that uses that sqlite file location and passes any arguments to it. The arguments in this instance will be the query which we will get to later:
Now let’s write the actual query logic to select from our alfred clipboard history:
And that’s it! We have a function that can now take in a search query and that runs the query against our Alfred sqlite database file. The entire script looks like this:
This is what the usage looks like:
Phew! That should be it! Feel free to tweet at us or DM us on instagram with questions!