Jump to content
FroZen_X

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

Share this post


Link to post

@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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post

@Andrew I came searching for a solution to the same problem (clipboard manipulation within a workflow resulting in duplicate/unwanted items). Is there any safer way in 2019 or with Alfred4 to do this now? Thank you

Share this post


Link to post
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.

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post
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".

Share this post


Link to post
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.

Share this post


Link to post
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.

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.

×
×
  • Create New...