Skip to content

Instantly share code, notes, and snippets.

@markhuyong
Last active December 4, 2016 07:19
Show Gist options
  • Save markhuyong/60949b1c9ccbd2a5d947d28dbd38345a to your computer and use it in GitHub Desktop.
Save markhuyong/60949b1c9ccbd2a5d947d28dbd38345a to your computer and use it in GitHub Desktop.
emacsclient settings
#!/bin/bash
socket_file=$(lsof -c Emacs | grep server | tr -s " " | cut -d' ' -f8)
if [[ $socket_file == "" ]]; then
# Just run Emacs (with any arguments passed to the script)
# It would be a good idea to parse the arguments and clean/remove
# anything emacsclient specific.
# (ie. -e should be --eval for emacs)
# note that emacsclient doesn't fix these args for you either
# when using -a / --alternate-editor
emacs $@ &
# or on OSX
/Application/Emacs.app/Contents/MacOS/Emacs $@ &
else
emacsclient $@ -n -s $socket_file
fi
#!/bin/bash
emacsdir=/Applications/Emacs.app/Contents/MacOS
socket=$HOME/.emacs.d/server/server
if [ ! -e $socket ]; then
$emacsdir/Emacs &
while [ ! -e $socket ]; do
sleep 1
done
fi
$emacsdir/bin/emacsclient \
--no-wait \
--socket-name=$socket "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment