cwd
cwd

Reputation: 54856

How to tell OS X not to "wait" during a bash script?

I've set up this script:

#!/bin/bash
/Applications/NameChanger.app/Contents/MacOS/NameChanger "$@"
osascript -e "delay 1" -e "tell application \"NameChanger\" to activate"

I'm using it to pass file names to NameChanager. Without the second line it loads NameChanger unfocused. I thought I should use a delay and then activate with applescript to get it focused.

Unfortunately the script is "waiting" for NameChanger to run and then to exit before executing the applescript bit. How can I change that?

Upvotes: 1

Views: 822

Answers (2)

sakra
sakra

Reputation: 65981

Alternatively you can use the open command to launch NameChanger. This should also automatically bring NameChanger to the foreground:

#!/bin/bash
open /Applications/NameChanger.app --args "$@"

Upvotes: 3

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799520

Append a & at the end of commands in a shell script that you want to run in the background.

/Applications/NameChanger.app/Contents/MacOS/NameChanger "$@" &

Upvotes: 2

Related Questions