Associate shell script as "Open With" application?

Discussion in 'Software Programming & Web Scripting' started by patniemeyer, Jun 3, 2004.

  1. patniemeyer

    patniemeyer Registered

    Joined:
    Jun 2, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I'd like ".txt" files on my desktop to open in vim in a new window in iTerm by default.

    So I figured out how to create a shell script with the appropriate osascript embedded in it to take an argument and do just that... tell iTerm to open a new window and load the file into vim.

    However when I go to try to make the file type association using "open with" from the finder, OSX won't let me choose my executable shell script (#!/bin/sh) as the application. Even if I check the "all applications" it is still grayed out.

    Does anyone have any idea of how OSX chooses which apps are "valid" for opening files and which are not?

    Or can someone tell me the correct way to do this? I'm gussing there is some way with folder actions...


    Thanks,
    Pat Niemeyer,
    Author of Learning Java, O'Reilly & Associates
     
  2. anarchie

    anarchie NSCoder

    Joined:
    Oct 22, 2002
    Messages:
    198
    Likes Received:
    0
    Trophy Points:
    0
    The app has to be in a valid .app bundle. It is possible to embed that shell script into an app bundle so it appears as an application, but you won't be able to have it open files, since the open-file mechanism involves Apple Events.

    Try making an Applescript application instead. Make sure it has the 'on open' handler.
     
  3. Lycander

    Lycander Registered

    Joined:
    Jun 25, 2003
    Messages:
    700
    Likes Received:
    0
    Trophy Points:
    0
    Did you chmod +x on the script?
     

Share This Page