Handle atom standard output from atom.sh

This commit is contained in:
Matt Colyer
2013-08-07 17:00:09 -07:00
parent c03e849089
commit 82882624ce

38
atom.sh
View File

@@ -1,5 +1,6 @@
#!/bin/sh
ATOM_PATH=/Applications/Atom.app
ATOM_BINARY=$ATOM_PATH/Contents/MacOS/Atom
if [ ! -d $ATOM_PATH ]; then sleep 5; fi # Wait for Atom to reappear, Sparkle may be replacing it.
@@ -8,7 +9,32 @@ if [ ! -d $ATOM_PATH ]; then
exit 1
fi
open -a $ATOM_PATH -n --args --executed-from="$(pwd)" --pid=$$ $@
while getopts ":whv-:" opt; do
case "$opt" in
-)
case "${OPTARG}" in
wait)
WAIT=1
;;
help|version)
EXPECT_OUTPUT=1
;;
esac
;;
w)
WAIT=1
;;
h|v)
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
# Used to exit process when atom is used as $EDITOR
on_die() {
@@ -16,16 +42,6 @@ on_die() {
}
trap 'on_die' SIGQUIT SIGTERM
# Don't exit process if we were told to wait.
while [ "$#" -gt "0" ]; do
case $1 in
-W|--wait)
WAIT=1
;;
esac
shift
done
if [ $WAIT ]; then
while true; do
sleep 1