1

I have a template set up in Snow Leopard's Terminal.app to create a new window or tab with my preferred emulation settings for a particular host that I use.

I'd like to assign a keyboard shortcut to that template so that I can quickly create a new window with those settings.

I tried using the Keyboard Shortcuts System Preference pane to do it. I can assign the shortcut key to the MyTemplate submenu, but it doesn't work when I try to use it. I suspect because the MyTemplate is listed in multiple submenus -- one for New Window and one for New Tab.

How can I assign a keyboard shortcut to my new fancy template?

PS. I do NOT wish to change my default (cmd-N) template.

emmby
  • 1,227

3 Answers3

2

Open Automator, create a new Service with the following Run AppleScript action (no input):

tell application "Terminal"
    activate # switch to Terminal, launch if necessary
    tell application "System Events"
        keystroke "t" using command down # open a new tab
    end tell
    set current settings of selected tab of front window to first settings set whose name is "MyTemplate" # switch settings to your template
end tell

The service will be accessible from the Services menu, and you can assign a shortcut in System Preferences » Keyboard » Keyboard Shortcuts » Services

Edited to add: You can specify whether you want this service to work globally by specifying any application or Terminal in Automator. Both work with this code, it just determined in which applications the service shows up.

Daniel Beck
  • 111,893
1

You could save a setup into .term file and then use a third party launcher (Quicksilver?) to start it from there.

0

I assume your suspicion is correct that the same item in multiple sub-menus is the problem. I've assigned keyboard shortcuts to submenu items without any problem when the string was unique.

Therefore, one approach would be to remove the "New Tab" menu item entirely. Try editing the user interface element that defines the menu.

Use plutil and the command line to make a compiled NIB editable, or there are some hints online about copying the compiled NIB into an application that uses uncompiled NIBS and then using Interface Builder.app.