Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

XPcentric

macrumors 6502
Original poster
Oct 16, 2008
271
0
For example there is in Mavericks under System Preferences, Keyboard, Shortcut, Services: "Open selected file in TextEdit". The problem is that I want to use a different editor, not only for a one type of file, but for any selected files, just like this example says, selected file.
I want to usually open configuration files, or files without extension and its too complicated to assign always open with for each file extension.

Programmers can help.


Edit

I found out that I have to edit the .plist in the package of the app, and I copied and changed the name of TextEdit with the app I want to use in the following code.

The problem is that the default shortcut does not even work for TextEdit. I don't understand what the problem is. I think some other people observed this bug before ?


<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Open Selected File in TextEdit</string>
</dict>
<key>NSMessage</key>
<string>openFile</string>
<key>NSPortName</key>
<string>TextEdit</string>
<key>NSSendTypes</key>
<array>
<string>public.plain-text</string>
</array>
<key>NSRequiredContext</key>
<dict>
<key>NSTextContent</key>
<string>FilePath</string>
</dict>
</dict>
 
Last edited:
Automator can make a Service.

You might want to google a tutorial on making Services with Automator for guidance.


You could also do what I do, and put an alias to your editor of choice on the Desktop, or keep it in the Dock, then drag files onto that icon to open them in the chosen editor.
 
I found an AppleScript which does that but I don't know how to assign a shortcut to it.

The idea with dragging is the best. Meanwhile I also want to find a way to assign file types (plain-text, UTF8, also those without extension) to be opened with my editor not with TextEdit.
 
Last edited:
I found an AppleScript which does that but I don't know how to assign a shortcut to it.

If I understand your question correctly, you'd:
1. Launch Automator.app.
2. Choose "Service" from the "Choose a type for your document" dialog.
3. Add a "Run AppleScript" action to the workflow.
4. Paste the AppleScript into the action.

You can choose options for what the Service receives, what applications it can be active in, etc. at the top of the workflow.

Then save it.

At this point, go to System Preferences > Keyboard > Keyboard Shortcuts tab, and choose the Services item on the left. Your new service will probably appear under General, at the bottom of the list. Select it and assign a keyboard shortcut.

So at a high level, the two main stages are:
1. Create the service in Automator.
2. Assign a keyboard shortcut to the service in System Preferences > Keyboard.


The saved service will be stored in a workflow file in your ~/Library/Services folder. The ~/Library folder is hidden by default in most recent OS X versions. You can easily get to it by clicking the Go menu in Finder, then holding down the option/alt modifier key, at which point "Library" will appear in the menu. Choose that menu-item and the folder will open.
 
Last edited:
Thank you it works perfectly with Automator.


Meanwhile I found out more about the traditional method how to make visible in the Contextual Menu "Open with..", but the shortcut only opens my editor app and it does not open the file as well. I was not too far...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.