Back to posts.

Auto start terminal app on mac

  • Open Automator
  • Drag an apple script element into the list
  • Paste this code (replace the command with your application)
on run {input, parameters}
   tell application "Terminal"
                do script with command "cd /Users/roxlu/application && ./app someflag"
        end tell
end run

Or, use the recommended solution which is a bit more work: For interactive installations this is what I commonly use and which is great for e.g. service like apps. You need to create 2 files: one shell script which actually starts the application and a launchd script/xml file which is loaded when the mac starts.
There are several paths where you can store a launchctl script:

Put your plist script in this folder if the job is only usefull when
users are logged in

Put your plist script in this folder if your job needs to run even when
no users are logged in

This is the most safe option for installations! This will start when
the users logs in (also when automated login is enabled)

1) This script will make sure that the application will restart if it crashes, every 10 seconds:

$ emacs                                                                                                                                                                      
while true
  cd /Users/roxlu/homerecordings/streamer/bin && ./streamer -f online.cfg
sleep 10

2) Create this file in your home dir: /Users/roxlu/Library/LaunchAgents (mac 10.8.x)

$ emacs com.homerecording.streamer                                                                                                                                                                      
<?xml version="1.0" encoding="UTF-8"?>                                                                                                                                                                  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">                                                                                                  
<plist version="1.0">                                                                                                                                                                                   

You can start a launch daemon using:

launchctl load /path/to/file.plist

And unload it with:

launchctl unload /path/to/file.plist

To check if your plist is loaded you can use something like:

launchctl list | grep "your label"