Skip to content

Instantly share code, notes, and snippets.

@tonyarnold
Created March 12, 2014 23:53
Show Gist options
  • Save tonyarnold/9519189 to your computer and use it in GitHub Desktop.
Save tonyarnold/9519189 to your computer and use it in GitHub Desktop.
GitHub's Atom expects to be in `/Applications` — I prefer to keep it in `~/Applications` with other non-AppStore apps. Unfortunately, this means that the command line `atom` command won't work out of the box. Update your copy of `/usr/local/bin/atom` to the following to have it work as expected no matter where it's installed on your Mac!
#!/bin/sh
ATOM_PATH=${ATOM_PATH-$(mdfind "kind:app Atom")}
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.
if [ ! -d $ATOM_PATH ]; then
echo "Atom application not found at '$ATOM_PATH'" >&2
exit 1
fi
while getopts ":wtfvhs-:" opt; do
case "$opt" in
-)
case "${OPTARG}" in
wait)
WAIT=1
;;
help|version|foreground|test)
EXPECT_OUTPUT=1
;;
esac
;;
w)
WAIT=1
;;
h|v|f|t)
EXPECT_OUTPUT=1
;;
esac
done
if [ $EXPECT_OUTPUT ]; then
$ATOM_BINARY --executed-from="$(pwd)" --pid=$$ $@
exit $?
else
open -a $ATOM_PATH -n --args --executed-from="$(pwd)" --pid=$$ $@
fi
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment