Emacs Org-mode's org-babel functionality. I have a few org-mode files storing all the dotfiles, put under version control. I can update and deploy them from within Emacs.
This is the most interesting system I've heard about for dotfiles. How do you organize the org files? Having a single org file with all my dotfiles in it could be interesting but probably unwieldy. It could be interesting to use code block expansion for keeping secrets out of the dotfile source.
I keep my emacs init in org and I can't believe I've never thought of this.
This is what I came up with over lunch. I'm going to try keeping all my dotfiles in one org file. I have an init hook that runs org-bable-tangle to re-export all the dotfiles after saving.
** Meta
If you place the following code into your emacs init when saving the
~/.dotfiles.org file the dotfiles will all be exported.
#+BEGIN_SRC emacs-lisp :tangle yes
(defun dotfiles-hook ()
"If the current buffer is '~/.dotfiles.org' the code-blocks are
tangled."
(when (equal (buffer-file-name)
(expand-file-name (concat (getenv "HOME")
"/.dotfiles.org")))
(org-babel-tangle)))
(add-hook 'after-save-hook 'dotfiles-hook)
#+END_SRC
** bashrc
#+BEGIN_SRC conf :tangle ~/.bashrc
export PATH=$HOME/bin:$PATH
#+END_SRC
** tmux
#+BEGIN_SRC conf :tangle ~/.tmux.conf
unbind C-b
set -g prefix C-t
bind C-t send-prefix
#+END_SRC
Thanks. Upvoted your solution, but I see some problems with this approach for my workflow:
1. I run emacs-server, so the init file is run only during restarts OR when I manually load it from emacsclient.
2. Re-exporting all dotfiles seems rather redundant. I prefer to selectively export individual dotfiles only when I have made changes to it. That's why I was interested in the 'deploy' part.
I am not familiar enough with Babel, but it definitely seems to offer a more centralized way of managing my dotfiles. It's going into TODO.