How to add custom keyboard shortcut for a nested menu item?

34

8

This has been bugging me for a couple years now. So in Mac OS X you can assign your own Keyboard Shortcuts (in System Preferences > Keyboard > Keyboard Shortcuts) by typing in the exact name of the menu item to which you intend to bind the keystrokes. So what are you supposed to type if:

  • the menu is nested? or
  • there are two menu items with the same name that do different things?

I don't care about special cases like Firefox. Please don't mention special cases, unless this is a special case where Apple failed it.


  • Example with Terminal: Shell > New Tab > Pro and Shell > New Window > Pro. I was using this as an example. I can't imagine that Terminal is the only app with this design flaw.

  • Another example from Pages: File > Duplicate and Edit > Duplicate. If you want to make Command-D duplicate, it'll set it for the edit menu but when that document gets locked, only the file menu has the option for duplicate, the edit menu is greyed out and the shortcut is locked to the unaccessible one.

Jim

Posted 2010-08-18T21:08:51.253

Reputation: 478

a) Nested menus usually work fine. – Vervious – 2010-08-18T23:03:09.320

1

If you don't want to re-define ⌘N, I haven't found a solution. This question was asked before: http://superuser.com/questions/118364/how-to-assign-a-keyboard-shortcut-to-a-specific-new-window-template-in-terminal-a/

– None – 2010-08-19T02:12:38.820

@Nano8Blazex nested works, but what about non-unique nested? – None – 2010-08-19T02:13:54.627

@mankoff that's the question! I commented before I realized that. And it is sort of a duplicate. – Vervious – 2010-08-19T03:51:57.703

If this is important to you, please file a bug report: http://developer.apple.com/bugreporter/

(If you don't already have one, it requires a developer account, but it's free.)

– Chris Page – 2011-10-12T05:01:28.987

Answers

7

There are two answers here, depending on exactly what your question is:

  • If what you want to do is just what your example states, try this:

    • Launch Terminal, and open its preferences ⌘,.
    • In the Settings preference pane, select Pro in the left-hand column.
    • At the very end of the left-hand column, click the Default button.

    At that point, you'll find that ⌘N now opens a new window in your preferred style, and ⌘T does the same for a new tab.

  • If your example was just an example, and it's some other app where you want to add a keyboard shortcut, you should be able to do it via System Preferences → Keyboard → Keyboard Shortcuts → Application Shortcuts → +.

    As @Nano8Blazex said, you can usually just enter the name of a nested shortcut and it will work fine.

Dori

Posted 2010-08-18T21:08:51.253

Reputation: 1 119

So, is it that non-unique menu items can't be reliably assigned a shortcut? – Jim – 2010-08-19T05:07:50.010

It depends—and of course, well-behaved Mac-like apps don't have duplicate submenu items. When I tried it with MS Entourage, though, it applied the keyboard shortcut to both menu items. Clicking the shortcut caused the right-most, bottom-most of the menu items to be triggered (which may or may not be what you want, of course). Creating a similar keyboard shortcut for Terminal, though, did nothing at all. – Dori – 2010-08-19T05:51:20.253

34

You can specify the shortcuts like Format->Indentation->Increase in 10.8 (thanks @JohanKaving), or >Format>Indentation>Increase in 10.7.

Another option would be to assign a shortcut to a script like this:

tell application "System Events" to tell process "Terminal" to click menu item "Pro" of menu "New Window" of menu item 1 of menu "Shell" of menu bar 1

Lri

Posted 2010-08-18T21:08:51.253

Reputation: 34 501

I can confirm that Format->Indentation->Increase still works in v10.11. And what a tremendous boon it is. – TransferOrbit – 2015-10-10T06:25:48.703

>

  • Thanks for the hint!
  • Did this ever work with 10.6?
  • I still use 10.6.8 and tried it with your syntax and some modifications -- ">" at the beginning or not, separators with spaces or not " > ", etc) -- but none worked. :-( – porg – 2012-11-28T17:34:08.427

    I think it was added in Lion but removed in Mountain Lion. There was a bug where you couldn't assign shortcuts to menu items that contained >. – Lri – 2012-11-28T20:32:23.713

    So no chance for this functionality in 10.6.8 ? – porg – 2012-11-29T03:02:50.953

    6Ir seems as if this functionality has not been removed in Mountain Lion - but it has changed. It works for me if i specify it as Format->Indentation->Increase – Johan Kaving – 2013-01-21T14:54:34.417