Is it possible to get fuzzy naming in select menu action?
I have several macros that use menu as part of their workflow. For examples one of them opens selected file in ForkLift with MacVim. I use main menu File > Open With which has a list of applications that is built dynamically based on selection. But the menu item corresponding with particular application is not always consistently named; sometimes it’s called “MacVim”, sometimes “MacVim (default)” and sometimes “MacVim 8.0.nnnn”. First two options are easy to handle, but last one has different number with each new version so I have to constantly update the macro. Can I specify the name of the menu item as regex, or otherwise use “fuzzy” naming?
In your case, I think regex naming might be the way to go. I don't have ForkLift or MacVim, so I can't test this myself, but theoretically something like this should work:
(As explained in the wiki link, the ^ at the start is what lets you use regex in menu items)
FYI if regex matching doesn't seem to work at all, it could be a subtle problem with the type of "caret" character that your Mac keyboard inserts when you press Shift-6.
Say you want to match a menu item like "Move to Folder1 again" knowing that it won't always be Folder1 in the middle.
This works: ^Move.*again
This does not work: ˆMove.*again
You want the ^ symbol -- not the very similar looking ˆ symbol
The one that works is what macOS considers:
^
CIRCUMFLEX ACCENT
Unicode: U+005E, UTF-8: 5E
You'll get that with the Mac keyboard layout set to U.S. or ABC Extended.
But for some reason, mine happened to be set to "U.S. International - PC". In that case, when you press Shift-6, you get a slightly different character that won't work for regex purposes:
ˆ
MODIFIER LETTER CIRCUMFLEX ACCENT
Unicode: U+02C6, UTF-8: CB 86
⇧6 followed by one of a,e,i,o,u produces â,ê,î,ô,û. But followed by a Space it gives you the big standalone Circumflex ^. (= The same as simply ⇧6 on the normal US layout.)
Oh good point Tom. That makes sense. I've set my keyboard back to regular U.S., but certainly for people who do want to use International, your suggestion is a much better approach.