Skip to content

Instantly share code, notes, and snippets.

@rfkm
Last active November 22, 2016 14:28
Show Gist options
  • Save rfkm/fc1439b68d297e68192b36a52c59e91f to your computer and use it in GitHub Desktop.
Save rfkm/fc1439b68d297e68192b36a52c59e91f to your computer and use it in GitHub Desktop.
#!/bin/bash -e
EMACS=${EMACS:-"open /Applications/Emacs.app -n --args"}
if [ $# != 1 ]; then
echo "Usage: alt-emacs </path/to/.emacs.d>" 1>&2
exit 1
fi
if [[ "$1" == */ ]]; then
emacs_dir="$1"
else
emacs_dir="$1/"
fi
init_file="${emacs_dir}init.el"
if [ ! -d $emacs_dir ]; then
echo "No such directory: $emacs_dir" 1>&2
exit 1
elif [ ! -f "$init_file" ]; then
echo "No such file: $init_file" 1>&2
exit 1
fi
init_form="(progn
(setq user-emacs-directory \"${emacs_dir}\")
(load \"~/${init_file}\")
(run-hooks 'after-init-hook))"
$EMACS -q --eval "$init_form"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment