Unfortunately there are no standard API's for this, BTT uses some dirty hacks to make this kind of work in most native apps, but in cases like this with dynamically added context menu items (coming from Finder plugins etc.) this can fail randomly. I don't think it is solvable for such context menus.
I'll have a look again, maybe for this specific case changing the internal timing behavior could help.
Ah I see thanks!
So how would I open iTerm2 with the current selection anyway without relying on context menu?
I don't really care about context menu if I can do it another way.
There is the "Open current Finder Selection With Specific App", but I think this would try to execute the file in iTerm.
Instead I'd use a little apple script:
tell application "Finder"
set sel to selection
if sel is {} then
display dialog "Select a file or folder in Finder first." buttons {"OK"} default button "OK"
return
end if
set theItem to item 1 of sel
if (class of theItem) is folder then
set targetPath to POSIX path of (theItem as alias)
else
set targetPath to POSIX path of ((container of theItem) as alias)
end if
end tell
tell application "iTerm2"
create window with default profile
tell current session of current window
write text "cd " & quoted form of targetPath
end tell
activate
end tell
I am also experiencing this with Finder. Trying to trigger the “Remove Download||Remove Downloads;” context menu item that removes local copies of files in iCloud Drive. BTT v6.380. Sometimes it just opens the context menu without triggering the item. About 25% of the time I’d say.
I guess I can try working around it by triggering ctrl + enter to bring up the context menu, delay next action, then send keystrokes “r, e, m, ”.
—————- followup – the commands “Remove Download” and “Remove Downloads” also appear in the Finder action menu in the toolbar, the icon with three dots. I was able to add the same keyboard shortcut for both command names in system settings → keyboard shortcuts, and it works perfectly!