Skip to content

Instantly share code, notes, and snippets.

@ryseto
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryseto/552afd67e162531a5020 to your computer and use it in GitHub Desktop.
Save ryseto/552afd67e162531a5020 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# You need to put the following in ~/.emacs.d/init.el.
# (if window-system
# (progn
# (require 'server)
# (unless (server-running-p) (server-start))))
#
EMACS_PID_ALL=`pgrep -d ' ' Emacs`
EMACS_ACTIVE=0
for EMACS_PID in $EMACS_PID_ALL
do
EMACS_CMD=""
[ -n "$EMACS_PID" ] && EMACS_CMD="`ps -p ${EMACS_PID} -o command | tail -1`"
EMACS_ACTIVE=`echo ${EMACS_CMD} | grep -q -e" -nw" && echo 0 || echo 1`
[ $EMACS_ACTIVE -eq 1 ] && break
done
[ $EMACS_ACTIVE -eq 0 ] && (open -a Emacs.app "$2" && sleep 1)
## Self-contained Emacs.app
/Applications/Emacs.app/Contents/MacOS/bin/emacsclient --no-wait +$1 "$2"
## Homebrew
#/usr/local/bin/emacsclient --no-wait +$1 "$2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment