How do I make "Open selected files with" shortcut ?

Discussion in 'Mac Programming' started by XPcentric, Nov 26, 2013.

  1. XPcentric, Nov 26, 2013
    Last edited: Nov 26, 2013

    XPcentric macrumors 6502

    Oct 16, 2008
    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.


    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 ?

  2. chown33 macrumors 604

    Aug 9, 2009
    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.
  3. XPcentric, Nov 26, 2013
    Last edited: Nov 26, 2013

    XPcentric thread starter macrumors 6502

    Oct 16, 2008
    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.
  4. chown33, Nov 26, 2013
    Last edited: Nov 26, 2013

    chown33 macrumors 604

    Aug 9, 2009
    If I understand your question correctly, you'd:
    1. Launch
    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.
  5. XPcentric thread starter macrumors 6502

    Oct 16, 2008
    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...

Share This Page