Starting application with custom keyboard shortcut
Solution 1
You have to deal with two issues here
- You can only assign keyboard shortcuts to applications' menu items and services. Terminal.app is neither.
- You cannot usually create a keyboard shortcut using
Esc
for Services in System Preferences » Keyboard » Keyboard Shortcuts.
Make sure a real application launcher such as Quicksilver, Alfred or LaunchBar wouldn't be the better solution.
For a Terminal, have a look at Visor. It allows you to create a HUD console. If you played Quake, you know how it works.
That being said, you can make this work.
First, create a Service by starting /Applications/Automator.app
and select the Service template. Select the Utilities library and double-click Launch Application. Select Other... from the popu-menu and then select /Applications/Utilities/Terminal.app
.
Above the Launch Application command, select no input and any application.
Press Command-S
to save, and name it Launch Terminal.
Now, Open System Preferences » Keyboard » Keyboard Shortcuts, select Application Shortcuts (not Services!). Click the +
button, and select All Applications. As name, type Launch Terminal
. Then, select the keyboard shortcut input field and press Command-Esc
. Click Add.
Done. Now there's a new menu item in Application Menu » Services named Launch Terminal, with the keyboard shortcut Command-Esc
, and selecting it starts Terminal.
Solution 2
There's a bug where the shortcuts for Automator services don't always work until the services menu has been shown once from the menu bar. And they won't be available in applications that don't have a Services menu. There's also a noticeable delay before they are run.
Using a third party application like Alfred would be a better idea.
You could also assign shortcuts to shell commands like open -a iTunes
.
This would block the script until the application has finished opening, so it would seem to take longer if it was run with FastScripts:
tell application "iTunes"
reopen
activate
end tell
Related videos on Youtube
![Igorio](https://i.stack.imgur.com/3NGJ5.jpg?s=256&g=1)
Igorio
Updated on September 17, 2022Comments
-
Igorio almost 2 years
Mac OS 10.6 has a "Keyboard Shortcuts" preference pane in System Preferences. It lets you add new entries, but they don't seem to work. Is this the correct way to add hotkeys? For instance I would like Command+Esc to open Terminal.app.
-
peelman over 13 yearsAs Daniel points out, you may want to look at something like Alfred.app or Quicksilver, or Google’s QSB project.
-
Doug Harris over 13 yearsI use and love Alfred, but you can also launch using Spotlight. If you're using Terminal often enough (or at least fewer than other apps starting with "T"), it might be as few as 3 keystrokes -- one to launch spotlight, one to enter "T", one to hit return to accept the first result found.
-
Igorio over 13 yearsNo need to repeat someone else's suggestion guys. Please leave comments for new information. I like alfred too, but I'm not asking about launchers.
-
-
peelman over 13 yearsA brillant hack :)
-
HikeMike over 13 yearsI'm pretty sure
Cmd-Esc
is used by some applications. Might be connected to theEsc
autocompletion. I could be wrong though. -
Igorio over 13 yearsI so wanted this to work, but the keyboard shortcut still doesn't launch terminal. I can select it from the menu, but that defeats the purpose of having a shortcut. (Daniel, yes front row uses that shortcut by default, which you can disable in the keyboard prefs)
-
HikeMike over 13 years@Ross It works for me with the shortcut. Could you try it with a new user account, maybe some background process interferes? You also should know that you need to change the active application once before the Services menu gets updated.
-
Igorio over 13 yearsRebooted, and this is what I've found. The shortcuts don't work right out of the gate. But if you go to the App menu > services they appear. This seems to 'refresh' or activate the service. After that the shortcuts DO work, but only in that app. Is this what you find as well?
-
HikeMike over 13 years@Ross No, I just launched an app from which I've never used a Service, and it could handle Cmd-Esc just fine without the menu requiring to be opened first. I'm on OS X 10.6.6. I recently saw a "Loading Services" message for the first time, but that was unfortunately before I assigned the keyboard shortcut. Have you tried it with another user account?
-
Igorio over 13 yearsIt does work with another user account, and now it appears to be working with my user account too. I'm baffled. Any idea which launchagent or daemon is responsible? On another note, this method launches apps slower than using a launcher app, not that it's your fault or anything, but the nice thing about shortcuts is the speed.
-
Igorio over 13 yearsWell thanks for the technical support, even though this isn't a solution I would use, you did a great job answering the question.
-
HikeMike over 13 years@Ross You can alternatively try using Butler or Keyboard Maestro.
-
HikeMike over 13 yearsI interpreted his answer as to not wanting third party software like launchers. So FastScripts, Apptivate etc. were out -- although they admittedly probably work better than my solution. I know about editing the plists, I explored this a while ago with @Arjan's help -- but I think you agree it's not usually possible, and quite easier to do using the named menu items shortcuts option. Btw, welcome to SU, I love your posts.
-
Igorio over 12 yearsThose don't look bad. I ended up using the "triggers" functionality of quicksilver which allows you to easily set hotkeys to launch apps. I use Alfred for non-hotkey launching though.