Jump to content

Clipboard Shuffler / Revolver / FILO Stack


Recommended Posts

Hey Forum,

 

I use Alfred's clipboard manager ~100 times per day, often in a terminal window. However I am using iTerm2's hotkey (⌥<Space>) window which opens the terminal as an overlay. Unfortunately, triggering the clipboard manager (⌥⌘C) causes the hotkey window to close. Thus, in order to paste several entries I paste one into the terminal then paste the next one into another application effectively moving it to the top of the clipboard stack and repeat.

 

It would be excellent if it was possible to do one of the following:

  • shuffle the clipboard (make the next item down active so that ⌘V would paste it)
  • pop the top item off the stack (pasting it and removing it the same way you can with ⌫)

 

I've done some searching and this seems to indicate that we cannot manipulate Alfred's clipboard manager. 

 

Alfred's clipboard manager is the best one I've used (searchable and no mouse required) but I'd be open to alternative suggestions

 

Thank,

Ben

 

Edited by bennyty
Link to comment
On 22/01/2017 at 2:46 AM, bennyty said:

Alfred's clipboard manager is the best one I've used (searchable and no mouse required) but I'd be open to alternative suggestions

 

This is what I don't understand about so many clipboard managers. Why would you even consider writing such an app that only works with a mouse?

Link to comment
On 1/26/2017 at 4:52 PM, deanishe said:

 

This is what I don't understand about so many clipboard managers. Why would you even consider writing such an app that only works with a mouse?

 

Agreed, along with searchability it makes Alfred a joy to use (except when it minimizes my pop-over window by stealing focus. I'd love if I was able to pull the first item in the stack with one keybind then the next then the next (maybe up to 5 or 9 deep?) if that would be easier than rearranging the stack.

Link to comment
  • 2 weeks later...

Bennyty, I am not sure I understand. Did you mean that you'd want to be able to copy items A, B and C (by hitting Cmd+C 3 times), and then paste them all (by hitting Cmd+V 3 times) getting C B A?

 

I ask because I am looking for that same feature (which I have seen elsewhere named "clipboard revolver", "clipboard stack" or "clipboard LIFO"), and I hoped that Alfred had this kind of thing. Alas it's looking like it doesn't. (I hope I'm wrong and someone would correct me?)

 

I see that the PowerPack does offer a clipboard merging feature, which might help if you actually want to paste together the different items. But that is not my general case.

 

FWIW, LaunchBar does this, but I'm not really happy with it (and my demo time is ending so I'm looking for alternatives). CopyQ seems to do this too and much more, but it's kinda complicated and I still didn't get into it. Looks like I will have to.

 

Link to comment

hmijail, you have it exactly right. I'm not sure why I didn't think to call it a LIFO/stack (I'm a computer scientist). I would also be happy with some sort of pointer into the stack that pastes and moves down on ⌥⌘V and resets to the top of the stack on ⌘V.

 

Alfred stores the clipboard at ~/Library/Application Support/Alfred 2/Databases/clipboard.alfdb perhaps I can write a script (later™) that could edit the SQLite3 database to pop the object off the "stack".

Link to comment

I have a hack that is almost working. I'm using BetterTouchTool to make a new key-shortcut that does 3 actions.

  1. Run terminal command: sqlite3 /Users/Ben/Library/Application\ Support/Alfred\ 2/Databases/clipboard.alfdb 'SELECT item FROM clipboard ORDER BY ts DESC LIMIT 1;' | pbcopy
  2. Trigger: ⌘V
  3. Run terminal command: sqlite3 /Users/Ben/Library/Application\ Support/Alfred\ 2/Databases/clipboard.alfdb 'DELETE FROM clipboard ORDER BY ts DESC LIMIT 2;'

This reads the most recent item from Alfred's database and copies it to the system clipboard. This has the side effect of adding it again to the Alfred database.

Then ⌘V pastes it.

Then we delete the two most recent items from Alfred.

 

Problem is, BTT is missing a way to wait for terminal command to finish; the method above is inconsistent because it pastes before the database and pbcopy resolve. I guess I'm currently waiting on https://github.com/fifafu/BetterTouchTool/issues/444. Any suggestions?

 

------------------------------------------------

EDIT: Currently trying an Alfred only solution. Similar issue as above (particularly that Copy to Clipboard & Paste is an output and can't be chained).

Alfred Workflow attempt:

 

Using Applescript:

do shell script "sqlite3 '/Users/Ben/Library/Application Support/Alfred 2/Databases/clipboard.alfdb' 'SELECT item FROM clipboard ORDER BY ts DESC LIMIT 1;' | pbcopy"

tell application "System Events" to keystroke "v" using command down

do shell script "sqlite3 '/Users/Ben/Library/Application Support/Alfred 2/Databases/clipboard.alfdb' 'DELETE FROM clipboard ORDER BY ts DESC LIMIT 2;'"

Has the same issue as it needs to pass the text through the clipboard again. Alfred takes some time to pickup on the clipboard change causing the sql-delete to delete the next entry instead of the duplicate. The ideal solution would be to use a bash script and pipe the output to Alfred's Copy to Clipboard & Paste action WITHOUT having it inserted into Alfred's clipboard.

Edited by bennyty
Link to comment

Oh wow. I'm ashamed to say that whenever I saw a database I just took a different route, and you just went and (almost) made it work. Thank you for your hacks. And, big respect! (and taking notes! ;))

 

What I can offer is that, after some minimal exploring of CopyQ, it looks more than promising. It's all about clipboard management, is open-source (available in brew too), useable from the CLI AND scriptable (in Qt Script/Javascript!). One of the example commands is "Paste and Forget", which sounds like it is very close to what we want; but it needs some adjustment, because its exact use case seems to be about first selecting some item(s) in its GUI palette. To be honest, the only problem I see in CopyQ is that it seems to include a wide range of kitchen sinks and I will have to go through them in case a LIFO was already there.

 

So, my plan before seeing your hacks was to keep using LaunchBar until its demo period expires in 2 days, and look into CopyQ in the meantime. Now I feel I should do it right now, but I'm too short on time :(. I will post again when I finally get into it.

 

For completeness: LB is supposed to keep working after its demo period, only with some nagging(?). So if LB's clipboard functionality keeps working after the free trial expires, then a possibility would be to just disable everything else in LB and stay with its "Paste and remove from history". (The things I don't like about LB is that every few seconds it uses about 9% CPU, and reads about 100 MB per hour from the HD, even with all of its indexing disabled; before I disabled it, it was still much worse). But now I'm pretty confident that CopyQ will be the long-term solution.
 

Edited by hmijail
grammar clarification
Link to comment
  • 3 months later...

Finally I got tired of dealing with LauchBar's demo mode and worked for a while with CopyQ. And it works perfectly; its main problem is the messy docs.

 

CopyQ generally captures everything that appears in the clipboard and puts it into a stack. (You can configure what formats to capture, what apps to capture them from, and put them into different stacks; plus you can edit them manually or through a script at capture time).

 

And one can also define their own script to react to a hotkey, and this is the script I ended with:

Quote

copyq:

select(0)

paste()

remove(0)

 

I attached this script to cmd+opt+ctrl+V. What it does is: select the latest copied clipboard contents from the current stack and put it back into the clipboard, paste into the current application, and pop that level of the stack.

(The only problem, which I think is even cute, is that if the stack is empty CopyQ shows for a second a notification of a runtime exception. I still didn't try dealing with that, since it keeps working)

 

Interestingly, if I am understanding right the docs a global hotkey-attached script like mine should not work for selecting rows in the stack. But evidently mine does.

 

(It uses about 0.1% CPU when quiescent... still too much ;P, but again good enough to live with it)

Link to comment
  • 7 months later...

Hey @bennyty,

 

Why do we need step 1 in your list? Isn't the most recent item in the database table by definition on the clipboard right now?

 

Just wondering why you included that--I suspect you have a very good reason--before I wasted time trying this out.

 

EDIT: Okay, I tried it. It does SEEM to work until I realized that while Alfred's in-memory history does reflect the row deletion, the system clipboard appears not to. It still has the original item in it.

Edited by toddp
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...