Created
February 17, 2013 05:39
-
-
Save tjluoma/4970344 to your computer and use it in GitHub Desktop.
An example of what you might do with the conditional shown in https://gist.github.com/tjluoma/4970335
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh -f | |
NAME="$0:t" | |
PPID_NAME=$(/bin/ps -p $PPID | fgrep '/sbin/launchd' | awk '{print $NF}') | |
if [ "$PPID_NAME" = "/sbin/launchd" ] | |
then | |
# This IS launchd, so send the message via growlnotify so it will be seen | |
msg () { | |
growlnotify --message "$@" "$NAME" | |
} | |
else | |
# This is NOT via launchd, so send the message to stdout via 'echo' | |
msg () { | |
echo "$NAME: $@" | |
} | |
fi | |
msg "Hello World" | |
exit 0 | |
#EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment