2013-02-23 08:49:37 +04:00
|
|
|
#!/bin/sh
|
2013-04-18 03:24:40 +04:00
|
|
|
ATOM_PATH=/Applications/Atom.app
|
2013-08-08 04:00:09 +04:00
|
|
|
ATOM_BINARY=$ATOM_PATH/Contents/MacOS/Atom
|
2013-04-18 03:24:40 +04:00
|
|
|
|
|
|
|
if [ ! -d $ATOM_PATH ]; then sleep 5; fi # Wait for Atom to reappear, Sparkle may be replacing it.
|
|
|
|
|
2013-04-27 03:07:45 +04:00
|
|
|
if [ ! -d $ATOM_PATH ]; then
|
|
|
|
echo "Atom application not found at '$ATOM_PATH'" >&2
|
2013-04-18 03:25:03 +04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-08-28 23:54:16 +04:00
|
|
|
while getopts ":whvft-:" opt; do
|
2013-08-08 04:00:09 +04:00
|
|
|
case "$opt" in
|
|
|
|
-)
|
|
|
|
case "${OPTARG}" in
|
|
|
|
wait)
|
|
|
|
WAIT=1
|
|
|
|
;;
|
2013-08-28 23:54:16 +04:00
|
|
|
help|version|foreground|test)
|
2013-08-08 04:00:09 +04:00
|
|
|
EXPECT_OUTPUT=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
w)
|
|
|
|
WAIT=1
|
|
|
|
;;
|
2013-08-28 23:54:16 +04:00
|
|
|
h|v|f|t)
|
2013-08-08 04:00:09 +04:00
|
|
|
EXPECT_OUTPUT=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $EXPECT_OUTPUT ]; then
|
|
|
|
$ATOM_BINARY --executed-from="$(pwd)" --pid=$$ $@
|
|
|
|
else
|
|
|
|
open -a $ATOM_PATH -n --args --executed-from="$(pwd)" --pid=$$ $@
|
|
|
|
fi
|
2013-02-23 08:49:37 +04:00
|
|
|
|
|
|
|
# Used to exit process when atom is used as $EDITOR
|
|
|
|
on_die() {
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
trap 'on_die' SIGQUIT SIGTERM
|
|
|
|
|
|
|
|
if [ $WAIT ]; then
|
|
|
|
while true; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
fi
|