↓ Skip to main content

Applescript script to emulate the behaviour of the `start' command in the windows CMD prompt

·1 min

People have asked me how to launch a pro­gram through the ter­minal in the back­ground but with it’s own ter­minal screen sim­ilar to the way the “start” com­mand in the Win­dows CMD prompt works. Well here it is. Add the fol­low­ing two files (start.applescript) and start to your path, and make them ex­ecut­able (chmod +x {start.applescript,start}).

One point of no­tice is to al­ways en­cap­su­late strings with spaces that should be one para­meter in quotes.

gistfile1.bash

# /usr/bin/env /bin/sh
start.applescript "`pwd`" $@

start.applescript

#! /usr/bin/env /usr/bin/osascript
on run argv
  
  tell application "Terminal"
    set AppleScript's text item delimiters to " "

    set cwd to first item of argv
    set l to rest of argv

    do script "cd " & cwd & " && " & (l as text)
    activate
  end tell

end run