7

I want to put my .spacemacs into Github, so I cloned it to a local directory. How to let Emacs use the .spacemacs in that directory instead of from the default ~/.spacemacs?

1
  • 2
    I've symlinked ~/.spacemacs to my version-controlled .spacemacs file.
    – alxndr
    Feb 16, 2016 at 4:56

2 Answers 2

5

In much the same way as Emacs loads ~/.emacs.d/init.el if it can't find a ~/.emacs file, so does Spacemacs load ~/.spacemacs.d/init.el if it can't find a ~/.spacemacs file.

This means you can create a ~/.spacemacs.d directory and rename the ~/.spacemacs file to ~/.spacemacs.d/init.el. Then you put the ~/.spacemacs.d directory on GitHub, and you're done.

If you have some private layers, you can also move them inside ~/.spacemacs.d/ and manage them in the same repository.

4
  • spacemacs uses already an init.el file - but you can nevertheless append the .spacemacs file to the init.el
    – toogley
    Nov 8, 2016 at 4:58
  • If you're talking about ~/.emacs.d/init.el, that's the entry point for Spacemacs code (technically Spacemacs is a configuration for Emacs). It loads ~/.spacemacs (or ~/.spacemacs.d/init.el), so there's no reason to append .spacemacs to ~/.emacs.d/init.el
    – bmag
    Nov 8, 2016 at 20:51
  • the reason to do that is to simplify storing the spacemacs config inside a git repo
    – toogley
    Nov 8, 2016 at 21:49
  • I can't see how this answer would work. emacs looks for ~/.emacs.d/init.el or ~/.emacs and only then are the Spacemacs configurations therein loaded.
    – joharr
    Sep 6, 2022 at 6:57
6

You can symlink your .spacemacs file. From a bash prompt:

$ ln -s /path/to/your/spacemacs-directory/.spacemacs ~/.spacemacs

You might find it easier to symlink the entire directory to a "dot directory," i.e. ~/.spacemacs.d, in which case you would do this:

$ mv /path/to/your/spacemacs-directory/.spacemacs /path/to/your/spacemacs-directory/init.el
$ ln -s /path/to/your/spacemacs-directory ~/.spacemacs.d
2
  • 1
    thanks, but I am using windows instead of linux
    – Daniel Wu
    Feb 16, 2016 at 8:51
  • 3
    Depending on your version of Windows, you can do the same using the mklink command. Create a directory symbolic link using mklink /D link target.
    – glucas
    Feb 16, 2016 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.