I'm working on a shell script to automate the way I install linux on my computers. I'd like to incorporate some emacs customizations into this script.
For example, as soon as emacs is installed, I'd like the following set:
- The init file should be in
~/.config/emacs/init.el
. menu-bar-mode
andtool-bar-mode
should both be set tonil
backup-by-copying
,delete-old-versions
,global-linum-mode
,line-number-mode
, andversion-control
should be set tot
kept-new-versions
andkept-old-versions
should both be set to5
backup-directory-alist
should be'(("." , "~/.cache/emacs-saves"))
Is there a way to automate this from a shell script?
I suppose that one way to do it would be to simply write these settings to the init file with something like
#!/bin/sh
mkdir -p ~/.config/emacs
cat > ~/.config/emacs/init.el <<EOF
'(menu-bar-mode nil)
'(tool-bar-mode nil)
'(kept-new-versions 5)
'(kept-old-versions 5)
'(backup-bycopying t)
'(delete-old-versions t)
'(global-linum-mode t)
'(line-number-mode t)
'(version-control t)
'(backup-directory-alist '(("." . "~/.cache/emacs-saves")))
EOF
init.el
. Will doing what I've suggested persistently set the init file as~/.config/emacs/init.el
? Also, I know that some people set these configurations within emacs withM-x customize-variable
. Are there advantages to this approach? If so, is this method scriptable? If what I have written is considered best practice, than I'm obviously very happy!