KM version of harpoon for Finder

Hello genial KM people!

Last time I had a very successful question on implementing a vim-like "leader key" in KM (link). I have another question here about implementing another well-known vim plugin: harpoon.

Basically, the idea of the plugin is that it allows you to mark a folder or file on your computer. A shortcut applied to the mark then allows you to access the location.

For example: cmd-1 to mark an open Finder location.

Then ctrl-1 to open that Finder location

The point is to allow you to very quickly bookmark and access folders without the overhead of creating manual named links. You may also want to use a keymap for 'next' and 'previous' to allow you to access the next and previous linked locations.

The point here is that during the week, you might constantly be working on 3-4 folders on your computer. Using this keymap, you can easily bookmark these folders, then immediately bring them up in a Finder window.

Is your question, "Can KM replicate harpoon's functionality?"

Perhaps you need to explain exactly what you mean by that. Do you have a design in mind? I could suggest a design for you, but I'm worried that my design wouldn't satisfy you. If you explain exactly what keystrokes you want to "bookmark" and "access" a folder, we could tell you if it's possible. My suggestion is CTRL-1 to save the current folder location in Finder and CMD-1 to re-open that location. Then you could do the same with -2, -3, etc. Is that what you want?

Hello!

You're right, that was confusing. For simplicity, lets say:

ctrl-1, ctrl-2, ctrl-3 to save the current folder location in Finder
cmd-1, cmd-2, cmd-3 to open the referenced location
cmd-shift-n to go to the 'next' location (n+1) from the current
cmd-shift-p to go to the 'previous' location (n-1) from the current

That's clearer, except for one thing. How does KM know what the "current" location is? Is it based on the CMD-N last performed, or is it based on the "current folder location" in the "front window" of the Finder (assuming Finder is in front)?

Honestly, I think the use of 'next' and 'previous' makes more sense for the original context of Harpoon (where you would toggle it to go to next and previous documents you're working on).

In this case, it's best just to ignore it for now. I can't think of a clear use case for it within Finder.

Usually when people ask me to write code I try to give them exactly what they asked for. But this time I thought I would write the interface the way I would want to see it written. If you don't like my approach, I will probably rewrite it the way you specified, but try out my approach first.

In my approach, every Finder Folder change is observed, and memorized. Then when you press SHIFT-CTRL-A, it will show you the last ten locations and let you pick one. If for some reason you want to erase its memory, press SHIFT-CTRL-Z.

Folder Memory Macro (v11.0.3)

Folder Memory.kmmacros (8.3 KB)

Hello, I just wanted to thank you for the attempt and reply, and also to note that it's on my todo list to test and compose a response! (work taking up a lot of time at the moment). Didn't want to be rude in the delay.

1 Like

Hello!

Thank you again for this. To be completely honest, I'm not a fan of this implementation. In general, my main problem is that the addition to the Finder list assembled seems very spotty. For example, if I open a Finder folder with Alfred or many other choosers, it doesn't seem to register on the list.

The idea of a chooser list is really nice but crucial in this shortkey request is the reliability of being able to assign a single toggle.

I would amend the original request like this:

ctrl-1, ctrl-2, ctrl-3 to save the current folder location in Finder
cmd-1, cmd-2, cmd-3 to open the referenced location
cmd-shift-n to go to the 'next' location (n+1) from the current
cmd-shift-p to go to the 'previous' location (n-1) from the current

C-S-A to raise a chooser window that shows

Shortcut | Folder

and then allows you to delete entries.

I realise I may be asking for something quite complicated, but hopefully the main idea of the request is clear.

There's nothing wrong with your request. And it doesn't seem too complicated. However there may be some ambiguous points. For example, how does KM determine your phrase "from the current" if there are several Finder windows open? In a case like that, I don't know what you want. I'll try to come up with an answer, but maybe you can indicate what you want.

By the way, Ctrl-Shift-Alt cannot be a trigger that takes any action like opening a window. So you may have to accept a different trigger. EDIT: maybe you meant CMD-SHIFT-A, although that was unclear, I think that's what you meant.

Currently I'm about 30% finished writing your required solution. However if someone beats me to it, that's perfectly okay with me.

EDIT: Currently I'm 60% finished. I got all the CMD and CTRL keys working. I just have the N, P and A keys to go. but like I said, the N and P commands are ambiguous and I'm going to have to guess what you wanted.

EDIT: I appear to be 100% finished. Let me test it out for a few minutes.

Apparently I have no idea how to export a macro group, so I will upload my 6 macros individually for you to import (below). Sorry about that. (I searched this site and I asked ChatGPT how to export a group, and I couldn't find the answer.) So here are my six macros...

Please try it out. If there's anything that doesn't meet your expectations, I can try again. It was fun coding this.

_CMD (open a folder, 1 to 3) Macro (v11.0.3)

_CMD (open a folder- 1 to 3).kmmacros (3.1 KB)

_CTRL (save a folder, 1 to 3) Macro (v11.0.3)

_CTRL (save a folder- 1 to 3).kmmacros (3.8 KB)

_Open (open the folder specified by the parameter) Macro (v11.0.3)

_Open (open the folder specified by the parameter).kmmacros (5.9 KB)

CMD-SHIFT-A Macro (v11.0.3)

CMD-SHIFT-A.kmmacros (3.6 KB)

CMD-SHIFT-N Macro (v11.0.3)

CMD-SHIFT-N.kmmacros (2.0 KB)

CMD-SHIFT-P Macro (v11.0.3)

CMD-SHIFT-P.kmmacros (2.0 KB)

2 Likes

Make sure no macros are selected and then either

  • Right-click on the Group and select "Export Macro Group"

or

  • Select Group and File -> Export -> Export Macros

Thanks for the solutions, Nige.

"Select group AND file"? I didn't know that you had to (or could) select both a "macro group" and a "bunch of macros" at the same time. That's a surprise to me. I've never had an app that required you to select items from two separate panes before it would work.

That's an even bigger surprise. I had no idea that some KM Editor menus would not show the same items that you get when you right click on an object. I spent a lot of time searching the menus for "Export Macro Group" and had no idea the only way you could see this menu item was by examining the pop-up menu for a macro group. Most apps I've used don't force you to use pop-ups to access functions.

It's probably just as well that I uploaded them individually, as that's the only way to "see" the macros. They are very short and use cool techniques that are worth "seeing."

Sorry, that really wasn't clear!

"Select the Group and then click the File menu, then the Export menu item, then the Export Macros menu item."

1 Like

@Airy this is...amazing

Okay, allow me to have a followup request. I tweaked this slightly and exported what you did as a Macro group. I also added a little notification upon saving the element, which is super useful for feedback.

Harpoon Macros.kmmacros (19.7 KB)

The question I have is: is it possible to extend this to windows instead of a Finder window?

Basically, this would allow you to quickly tag any window under this system. Originally I asked for Finder windows, but I realise that it would be much more powerful if it worked for all windows. So again, a shortcut like ^1 to tag a window, then cmd-1 to recall it.

If the window corresponds to an un-open app, then in theory you could launch the app. But I think this is largely unnecessary, since the main utility of this is to allow fast switching between windows.

I imagine the 'menu' macro is not so useful, but the previous/next might be (I think they are still secondary though). In reality, this is eventually emulating the macOS Desktops functionality (so you could in theory create a layout instead of a window under a tag: you then tag a layout of windows, then it's useful to go 'prev' and 'next' to switch between layouts). In actuality, this probably get excessively complicated...

I'm glad you like it. I like helping people, and showing how amazing KM is. Have you been using it? Does it work? Do you like how the hotkeys work? Personally, I'm not sure I like reserving that many hotkeys.

Actually, my macros are pretty nice, but whenever I rewrite my macros, I usually make them better. These macros are no exception... they could be made slightly better, too. I did write them in a way that you could easily add a 4th or 5th shortcut if you wanted to.

Do you understand how my macros work? There are some sneaky techniques I use that may not be clear to you. I'd be happy to explain them if you have questions.

Perhaps. I would need to think about it for a while.

The main problem appears to be that you are under the impression that "apps" and "windows" are synonymous. (Many people think that way.) But they aren't. Most apps can have multiple windows. So it's not clear what you really want. E.g., if you have Pages, Keynote and Numbers all open, each with three windows, what are you wanting to happen in that case? it's not clear to me what you want. I need to ponder what your request actually means.