2 of 6 forgot to explain the fs structure the script expects

I want to use several emacs configurations/versions simultaneously…

…so I came up with the following script, which assumes that alternate configurations are stored in ~/alternate-emacsen/<name-of-config>. I use this eg. to test emacs26 pre-release while working with a plain emacs25 and being able to use spacemacs, doom emacs or any variant configuration whenever I want to.

The script resides in ~/bin and assumes that <name-of-config> and the name of the softlink which calls it are identical; eg. if you want to launch the config stored in ~/alternate-emacsen/deepin-emacs you need a softlink ~/bin/deepin-emacs.

Be sure to put .emacs.d inside the <name-of-config> directory since the latter is used as a fake home directory, so that the actual ~/.emacs.d and ~/.emacs do not get touched.

If you think this is useful or suits your needs, feel free to use it.


# alternate-emacsen ––  A bash  script to launch  Emacs in  completely different
#                      configurations,   like   GNU   default,   Deepin   Emacs,
#                      Spacemacs, CL  server,… from  their own  config directory
#                      trees.
# Usage:
# – create  a  directory  $HOME/alternate-emacsen/,  containing  an
#   .emacs.d with all the base configuration  inside it.  Put the init file into
#    if necessary.
# – create a link  to this script, eg.
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/emacs-unstable
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/spacemacs
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/doom-emacs
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/deepin-emacs
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/prelude-emacs
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/emacsstarterkit
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/exwm
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/clemacsd
# – set  $emacsbin  to   the  emacs  version  you  prefer/use.  or   set  it  to
#   /usr/bin/emacs  for  the  system's  default.   I  use  emacs-25.2  with  the
#   Athena/Lucid X widget set  as my default GUI (not GTK because  I do not like
#   it for several reasons), so it is set as default.
# – edit the  emacs2x entries to reflect  your preferences like in  the previous
#   step.

self="emacs config launcher";
emacsconfig=`basename $0`;

test -d "$HOME" || { \
             echo "$self: ERROR –– $HOME does not exist!";
             exit 1;

# On my system, Emacs 23.2/GTK2 (in /usr/bin) is the default, but I prefer Emacs
# 25  with pure  X11  Lucid interface.   Also, the  system  default uses  partly
# incompatible ELisp packages (both to Emacs 23  and Emacs 25), so I ignore them
# by not using /usr/share/* at all (the  other Emacsen are compiled to reside in
# /usr/local and thus ignore the outer /usr tree).

case $emacsconfig in
        ;; # use emacsbin as defined in the settings

export HOME;
unset userhome;
cd $HOME;
if test -e "$emacsbin"; then
    $emacsbin $@
else echo "$self: ERROR –– not found: $emacsbin";