1

I'm trying to have a shell script run and then close itself but not quit Terminal all together. Here's what I have:

#!/bin/sh

while [ "$JOB_NUMBER" = '' ]; do
    echo -n "++++++++++++++++++++Job Number: "
    read -e JOB_NUMBER
done

echo "Opening Job Number: $JOB_NUMBER's folder"
open -g /Volumes/OSX_0*/$JOB_NUMBER*
sleep .5
osascript -e 'tell application "Terminal" to quit' & exit

but the AppleScript here quits Terminal where I'm just trying to close that window

1 Answer 1

0

Here is one way to do it,

  1. In Terminal, find a preset profile you like and make a duplicate of it.
  2. Under shell section, tick Run command: and enter your script
  3. Untick Run inside shell, and below this
  4. Select Close if the shell exited cleanly
  5. Make any additional changes and...
  6. Export it to a .terminal file.

The result is a custom window, colors, size etc that will close once your script exits successfully (ie exit code 0). You can also remove the Applescript bits from your script.

You can now launch your script with open AutoClose.Terminal or just double click it from Finder.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .