Jump to content

How to delete Last Clipboard entry


Recommended Posts

Hello everyone,

 

is there a way to delete the last Clipboard entry in Alfred?

I'm currently using Keyboard Maestro to select the last word, capitalize it and paste it back. The Problem there is that

it manipulates the Alfred clipboard so that i have the entry twice. Like there stands "test" and "Test". I would like to 

delete those.

 

 

Cheers,

Frozen

Link to comment

@FroZen_X you can delete individual items manually using cmd+backspace in the clipboard history viewer.

 

If you could set Keyboard Maestro to use a transient marker when populating the clipboard, then Alfred's history will ignore this. Alternatively, you could setup an Alfred workflow to do a similar task, and Alfred's Clipboard output object can set the text as transient.

 

Cheers,

Andrew

Link to comment
On 10/03/2017 at 10:39 AM, Andrew said:

@FroZen_X you can delete individual items manually using cmd+backspace in the clipboard history viewer.

 

If you could set Keyboard Maestro to use a transient marker when populating the clipboard, then Alfred's history will ignore this. Alternatively, you could setup an Alfred workflow to do a similar task, and Alfred's Clipboard output object can set the text as transient.

 

Cheers,

Andrew

 

haven't found a way to use transient marker with keyboard maestro so ill use Alfred exclusively for this :)

Thank you very much for your reply.

 

Cheers,

Frozen

Link to comment
On 10/03/2017 at 10:39 AM, Andrew said:

@FroZen_X you can delete individual items manually using cmd+backspace in the clipboard history viewer.

 

If you could set Keyboard Maestro to use a transient marker when populating the clipboard, then Alfred's history will ignore this. Alternatively, you could setup an Alfred workflow to do a similar task, and Alfred's Clipboard output object can set the text as transient.

 

Cheers,

Andrew

 

 @Andrew I actually have another issue here when i wanna get this to work with Alfred. I can dispatch a keycombo ⌘ + C to copy the text, but that one cannot be marked as transient. The output copy to clipboard doesn't let me get selected text like the Hotkey function does. Is there any way to get the Dispatch Keycombo

mark the clipboard as transient or get the selected text via an action like the Hotkey one?

 

This is my current idea of doing:

 

press a shortcut → dispatch keycombo "⌘+⌥+ ←" → dispatch keycombo "⌘+C" and then Transform and paste.

 

Else ill have to use some applescript i guess.

 

Cheers,

Frozen

Edited by FroZen_X
Link to comment
8 minutes ago, FroZen_X said:

Is there any way to get the Dispatch Keycombo mark the clipboard as transient or get the selected text via an action like the Hotkey one?

 

This isn't really possible at the point of dispatching a key combo (without bodging) as it's the responsibility of the app placing the data into the clipboard to add a transient marker as one of the data types (which will be the app in focus).

 

One thing you could do seeing as you have the text you've copied, is add a very short delay (utility object) to the end of your workflow, then a bash script delete from Alfred's clipboard history SQLite DB where the text is equal to the text you have at hand. Alfred's clipboard DB only stores unique items, so you could use the following command in a shell script:

/usr/bin/sqlite3 ~/Library/Application\ Support/Alfred\ 3/Databases/clipboard.alfdb 'DELETE FROM clipboard WHERE item = "TEXTHERE" AND dataType = 0 LIMIT 1;'

You'd have to replace "TEXTHERE" with a the actual text, and ensure that this is correctly escaped for the SQL query.

 

NOTE: While this will work at this point in time, this is quite an advanced thing, and I don't usually recommend messing directly with the clipboard database. Having said that, it should work ok for now.

 

Cheers,

Andrew

Link to comment
  • 2 years later...
5 hours ago, luckman212 said:

Is there any safer way in 2019 or with Alfred4 to do this now?

 

Do what exactly? What is your workflow trying to achieve?

 

What I mean is, this might be an XY problem. @FroZen_X's initial problem could likely have been solved by having Keyboard Maestro type the altered text instead of putting it back on the pasteboard, for example.

Link to comment

Ah ok. Yes I am familiar with the XY problem ( I don't think this is a case of it)

 

What I am doing is triggering a "copy macOS selection" via Hotkey, then performing a trim operation on it, and copy the result back to the clipboard. 

 

I only need the final trimmed result, not the intermediate clip. So I would like to delete "{clipboard:1}" basically. Or, prevent it from ever reaching the history.

Link to comment

I think I'm already doing that (screenshot below) — I still end up with 2 clipboard items added each time the workflow is called. I'm calling the hotkey from Contacts.app, but I've tested the behavior from other apps such as Sublime Text, Evernote etc and it's the same result.

 

I'm linking a test workflow here so you can try it out and see what I mean. If you can get this to work I would love to know how!
https://github.com/luckman212/alfredworkflows/blob/master/SpecialCopy.alfredworkflow.zip

 

image.png.eadfcce2c681ad5df0b862be4cc7b954.png

Link to comment
On 8/21/2019 at 10:52 PM, luckman212 said:

I still end up with 2 clipboard items added each time the workflow is called

 

There doesn't appear to be anything you can do about that other than use sqlite3 to manipulate the clipboard database.

 

TBH, I would file a bug report about this. Alfred does restore the clipboard after getting the current selection, so the intention is clearly to pretend it was never on the clipboard—as with Alfred's snippets. That it ends up in Alfred's clipboard history is therefore likely not the desired behaviour.

 

FWIW, I use Copied for my clipboard history manager, and interestingly enough, it doesn't record the item created by Alfred's "Get Selection".

Link to comment
21 hours ago, deanishe said:

TBH, I would file a bug report about this.

 

Thanks- I'll do that. I used to use Pastebot for clipboard history, and I also own Copied. Pastebot was nice because it also synced the history via iCloud to all my Macs, but when I got Alfred, it's clipboard was "good enough" and so I got rid of Pastebot to simplify.

Link to comment
3 hours ago, luckman212 said:

it also synced the history via iCloud

 

That was one of the reasons I chose Copied, but it doesn't encrypt the history before putting it in iCloud, so I turned that feature off :(

 

I've never really liked Alfred's clipboard history. Too much preview pane and not enough list.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...