How do I launch applications from Terminal?

Discussion in 'Mac Apps and Mac App Store' started by bamafan, Oct 2, 2006.

  1. bamafan macrumors newbie

    bamafan

    Joined:
    Oct 2, 2006
    #1
    I am an experienced UNIX user, and am learning the ropes with my first Mac computer. I have one of the new iMacs (Intel core duo processor) and am running OS X 10.4.

    I am trying to figure out how to lanuch an application from the Terminal, and I'm having no luck. On a typical UNIX system (Sun Solaris is what I'm most familiar with), you can just type the name of the application to launch, but it's not working for me from the Mac Terminal. I have tried to execute the application using all of these methods:

    <work>$ TextEdit
    </Applications>$ ./TextEdit
    <work>$ TextEdit.app
    </Applications>$ ./TextEdit.app

    All of these attempts result in the "no such file or directory" error message. I have tried to launch the apps from the /Applications directory where the actual application files exist, and still no luck. I have checked the permissions, and the applications do have executable permissions (rwxr-xr-x).

    I've also added /Applications to my path, but that's not working either.

    Any suggestions? Thanks.
     
  2. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #2
    The applications are actually, for the most part, folders of files (right-click on an app and select "Show Package Contents").

    They're not really "made" for running directly from Terminal, but something like
    Code:
    /Applications/TextEdit.app/Contents/MacOS/TextEdit
    will work.

    Or just open a file of the appropriate type, like this:
    Code:
    open sample.txt
     
  3. therevolution macrumors 6502

    Joined:
    May 12, 2003
    #3
    Here's another way to do it that's sort of a mix of jsw's examples:

    Code:
    open /Applications/TextEdit.app
     
  4. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #4
    You can also:
    Code:
    open /Applications/TextEdit.app
     
  5. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #5
    Ah... I'd never used the open/app combo. Silly me. :eek: I tend not to open GUI apps from Terminal.

    Yes, that's a much better approach.
     
  6. bamafan thread starter macrumors newbie

    bamafan

    Joined:
    Oct 2, 2006
    #6
    Thanks for the quick response.

    One more question: Does the "open" command launch the default application for that file type (based on the file extension)? If so, how do you update the default application? I've just installed Vim for Mac, and that's the application I'm trying to use as my editor. Is there any way I can make "open" launch Vim instead of TextEdit?
     
  7. mkrishnan Moderator emeritus

    mkrishnan

    Joined:
    Jan 9, 2004
    Location:
    Grand Rapids, MI, USA
    #7
    You can update the default app graphically by right / ctrl-clicking the document and then choosing the open with.. option, selecting the appropriate item, and selecting the button to always use that app. Very similar to Windows.

    I think there's also an -a flag for open that lets you specify the app....
     

Share This Page