with-emacs.sh icon indicating copy to clipboard operation
with-emacs.sh copied to clipboard

Script to easily run Emacs with specified configurations

#+TITLE: with-emacs.sh

#+PROPERTY: LOGGING nil

Note: This readme works with the org-make-toc https://github.com/alphapapa/org-make-toc package, which automatically updates the table of contents.

This script makes it easy to run Emacs with alternative configurations (i.e. not =~/.emacs.d=). For example, to run Emacs with a configuration stored in =~/new-emacs.d=, simply run:

#+BEGIN_SRC shell $ with-emacs.sh --dir ~/new-emacs.d #+END_SRC

It can also use temporary, "sandbox" directories that are automatically created and then removed after Emacs exits: just run =with-emacs.sh= without specifying a directory.

It's helpful for developing packages, troubleshooting configuration problems, trying out alternative configurations, etc.

  • Contents :noexport: :PROPERTIES: :TOC: this :END:
  • [[#installation][Installation]]
  • [[#usage][Usage]]
  • [[#changelog][Changelog]]
  • Installation :PROPERTIES: :TOC: 0 :END:

Copy =with-emacs.sh= into your =PATH= (or don't, and run it from wherever you want).

  • Usage :PROPERTIES: :TOC: 0 :END:

#+BEGIN_EXAMPLE with-emacs.sh [OPTIONS] [EMACS-ARGS]

Run Emacs with a specified configuration directory. If no directory is specified, a temporary one is made with "mktemp -d" and removed when Emacs exits.

Options --debug Show debug information and don't remove temp directory. -h, --help This. -- Optionally used to separate script arguments from Emacs arguments.

-d, --dir   DIR            Use DIR as user-emacs-directory.
-e, --emacs PATH           Run Emacs executable at PATH.

-i, --install PACKAGE      Install PACKAGE.
-O, --no-org-repo          Don't use the orgmode.org ELPA repo.
-P, --no-package           Don't initialize the package system.
-R, --no-refresh-packages  Don't refresh package lists.

#+END_EXAMPLE

  • Changelog :PROPERTIES: :TOC: 0 :END:

** 0.1.2

Changes

  • Use ~#!/usr/bin/env bash~. (Thanks to [[https://github.com/benoitj][Benoit Joly]].)

** 0.1.1

Fixes

  • Argument =-e= / =--emacs=.

** 0.1

First tagged version. Renamed from =emacs-sandbox.sh=.

  • Credits :PROPERTIES: :TOC: ignore :END:

Inspired by and some code copied from [[https://github.com/melpa/melpa][MELPA]]'s Makefile.

  • Alternatives
  • [[https://github.com/plexus/chemacs2][Chemacs2]] is a system of three Elisp files designed to replace your =~/.emacs.d= and switch between "profiles" stored in other directories. It requires a configuration file pointing to the profiles' directories. It offers some additional functionality, like setting environment variables per-profile.
    • In contrast, =with-emacs.sh= does not replace anything, and it requires no configuration; just run it with a directory of your choice. It's just a Bash script, so if you want to set an environment variable, use standard tools, like =env=.
  • Development :PROPERTIES: :TOC: ignore :END:

Bug reports, feature requests, suggestions — /oh my/!

  • License :PROPERTIES: :TOC: ignore :END:

GPLv3

Local Variables:

eval: (require 'org-make-toc)

before-save-hook: org-make-toc

org-export-with-properties: ()

org-export-with-title: t

End: