How can I open a file with an application, other than the default, using a keyboard shortcut? I don’t want to change the default application for the filetype.
E.g. sometimes I want to open a .html file using an editor instead of a browser.
The best solution for me:
For example I want to open HTML-file with Sublime Text instead of Chrome. I navigate to this file, press shortcut, type in "su", press down-arrow and press enter!
I'm afraid there's no such shortcut. You can, though, create your own.
To do so just:
Other...
instead of Open with
.You'll be able to test the shortcut right away. Just mind the Open always with option!
Always Open With
(10.7.5): The keyboard shortcut pref and the error message
Other...
does work. (It does amaze the programmer in me though that there is an implicit assumption that the menu items should have unique names. What if another submenu has an Other
? But that is beyond this question...)
If you frequently open a file in a specific app (other than the default app), you can set a keyboard shortcut for doing it. This is super easy.
Let's say you want to open a file in Sublime Text whenever you press control+S after selecting the file.
Now you can simply select the file and press control+S to open the file in Sublime Text.
As requested , here is a capture of [my blog] post for an Automator Service that works for me in Yosemite .
Code for Applescript in step 2
on run {input, parameters}
tell current application to activate
end run
Code for Applescript in step 5
on run {input, parameters}
set theApp to (POSIX path of (item 1 of input))
repeat with i from 2 to number of items in input
set this_item to item i of input
tell application theApp to open this_item
end repeat
tell application theApp to activate
end run
After Saving the Automator Service go to System Prefs. and add your shortcut to it.
I have used FastScripts to assign a shortcut to this script. It can also be used to select the open recent menus in other applications.
try
set l to {"Open With", "Open Recent", "Open Recent File", "Recent Projects", "Open Recent Set"}
tell application "System Events" to tell (process 1 where it is frontmost)
tell menu bar item 3 of menu bar 1
click
repeat with x in l
try
menu item x of menu 1
click menu item x of menu 1
exit repeat
end try
end repeat
end tell
end tell
end try
I also used scripts like in 10.6 and earlier:
try
tell application "Finder"
open (get selection) using path to application "TextMate"
end tell
end try
There is a bug that makes them unusable in 10.7 and 10.8 though. It could be avoided by focusing another application at the start, but it results in a visual glitch.
You could also use Automator services, but there is another bug where the shortcuts for services don't always work until the services menu has been shown from the menu bar.
My favorite solution is using Better Touch Tool, a free app. For this to work you need to have Full Keyboard Access turned on (in system preferences - keyboard preferences - shortcuts), so that ctrl-f2 will access the menu bar.
Then use BTT to configure your short-cut (I use ctrl-alt-cmd-O) to do ctrl-f2, then attach addtional actions (10 times: two right arrows, then 7 down, then one right). When typing your shortcut you will get to the same submenu as you would get using the right mouse click and 'open with'.
Note that ctrl-f2 may not be displayed in BTT when you type it, but it does after you do 'attach additional action'.
Right click on the file > press h key > use arrow keys to navigate
Cmd Shift /
, then start typing the name, and use the down arrow to selectOpen With > App