1

It used to be possible (on macOS 10.14 below at least), to set up a keyboard shortcut to open up a specific terminal profile:

enter image description here

Unfortunately, on macOS 12 and later (at least, I never ran 10.15 or 11), this no longer works. The menu highlights as it seems to recognize the keyboard shortcut, yet it doesn't open a new window (or tab). I am guessing that this is because it recognizes the command in two different places, both in the New Window submenu, as well as the New Tab submenu. On 10.14, only the New Window > Man Page had the keyboard shortcut listed.

Is there any way to have this work again? I tried adding "New Window > Man Page" as the command option, but that didn't work.

0

2 Answers 2

1

Edit: Ha! I figured it out! AppKit has always had this functionality! You just need to execute a command like this, which writes a NSUserKeyEquivalent with 0x1B (ASCII ESC, \e, \033) as seperator between the titles in the title path:

defaults write com.apple.Terminal NSUserKeyEquivalents -dict-add $'\eShell\eNew Window\eMan Page' '@$m'

…or you can also just type Shell->New Window->Man Page in the "Menu title" field in system settings, which does this for you.

source: decompile AppKit and search for "titlepathbased" strings; landed on -[NSMenuItem _fetchFreshUserKeyEquivalentInfo] which mentions r13 = loc_7ff841d3cc10(rbx, @selector(componentsJoinedByString:), @"\x1B");. Also referenced this apple community question. This also answers your question.

Tested pass on Ventura 13.4 22F66.

ORIGINAL ANSWER:

I think you are using the "NSUserKeyEquivalents" feature in AppKit, which apple calls "App Shortcuts". Apple does not let you use a menu path there, and when multiple items share the same name, like in Terminal.app, strange things happen. Shortcuts may work the first time but from the second time appkit will invoke another one with the same name (which you can tell by watching the menu bar item blink).

AppKit does have a global variable called _hasTitlePathBasedUserKeyEquivalent, which may signal that with some hacking we can make it do what you want. Until then, you will want to check out some third-party productivity tools that may hack macos or invoke the menu title indirectly.

0

@hym3242 posted a better solution, but if it stops working for whatever reason:


You can use an Automator action which runs an AppleScript to open a new terminal window with a specific action.

Create a new Automator "Quick Action", drag in the "Run AppleScript" block, then from this answer, I modified the code to this:

tell application "Terminal" to launch
tell application "System Events"
    set terminal to application process "Terminal"
    set frontmost of terminal to true
    click menu item "Man Page" of ¬
        first menu of menu item "New Window" of ¬
        first menu of menu bar item "Shell" of ¬
        first menu bar of terminal
end tell

Which needs to be pasted into your code block in Automator. If you're testing this in Automator/AppleScript Editor, you'll need to grant them permission to control the computer. Save it with a name like "Open Man Page". Then go into the Keyboard Shortcuts prefs, and add your shortcut to your new quick action listed under "Services". If it's the same as the one you used to use for terminal, make sure to remove that from the App Shortcuts section first, or it will override it. The first time you run it you'll need to enable terminal's ability to control your computer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .