Shortcut to terminal app with arguments and without terminal remaining open

Discussion in 'macOS' started by therealmuffin, May 10, 2011.

  1. therealmuffin macrumors newbie

    Joined:
    Jun 5, 2008
    #1
    Howdy,

    I have an application (GMPC) that is started from terminal. I can create a shortcut to that program with "ln -s 'loc. program' name_shortcut". However, I would like to pass an argument to it (like --fullscreen). In addition I would like the terminal window not to remain open. I was wondering if one or both are possible.

    Thanks in advance, Maarten
     
  2. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #2
    I'm not sure about the argument but you can close Terminal with the command "killall Terminal".
     
  3. jtara, May 10, 2011
    Last edited: May 10, 2011

    jtara macrumors 65816

    Joined:
    Mar 23, 2009
    #3
    But that will kill any sub-processes of the terminal application as well. That would mean the application that was launched from the terminal...

    What you are creating is not a "shortcut", though, but simply a symbolic link. It's just an alternate name for a file in the filesystem. It doesn't allow you to set command-line parameters, the working directory, or environment variables, as you can with desktop shortcuts. Indeed, a symbolic link has no knowledge of file content - it's unaware whether the file is an application or a data file.

    Unfortunately, OSX (despite being the "superior" GUI) lacks this capability which both Windows and Linux have.

    Best you can do is create an Applescript. See here for a discussion:

    http://macosx.com/forums/howto-faqs...and-line-apps-scripts-finder-applescript.html

    Looks like MacScriptGUI is the closest thing you'll find to a Windows/Linux desktop shortcut.
     
  4. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #4
    I'm not familiar with that app. Does the app run in Terminal, or does it only get launched in Terminal? If the app has already been launched, it won't be affected if you quit Terminal. If you need Terminal to remain running, go to
    Terminal > Preferences > Settings > Shell and select "When the shell exits: Close the window"
    Then when you type "exit" in Terminal, it will close the window but leave Terminal running.
     
  5. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #5
    If the application in question is a faceless background application, and you simply want to start it with arguments, then quit the Terminal - this is actually easy to do.

    Make a little plain text file with a .command extension (instead of .txt), and put this in it:
    Code:
    #!/bin/sh
    /path/to/program argument1 argument2 &
    killall Terminal
    That ampersand at the end tells Terminal to run the application in the background, effectively detaching it from the shell session.
     
  6. therealmuffin, May 11, 2011
    Last edited: May 12, 2011

    therealmuffin thread starter macrumors newbie

    Joined:
    Jun 5, 2008
    #6
    Thanks all for your input. That little shell script works like a charm.

    Maarten

    ps. GMPC runs in X11 and is a client musicplayer/controller for a music database (Music Player Daemon or MPD).
     

Share This Page