3 ms·
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 wit
by celadevra_ 11y ago
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.
- hellofunk 11y agofascinating. never heard of doing something like this, though i use emacs all day long (but not org mode -- didn't even know org mode could do this).
- stevekemp 11y agoYou might enjoy this then: https://github.com/skx/dotfiles/tree/master/.emacs.d https://github.com/skx/dotfiles/tree/master/.emacs.d In there you'll find ~/.emacs/init.el which parses ~/.emacs/init.md which is a markdown file containing both documentation and executable Lisp. There are other files in separate directories/packages, but I like the idea of placing everything in one readable file: https://github.com/skx/dotfiles/blob/master/.emacs.d/init.md https://github.com/skx/dotfiles/blob/master/.emacs.d/init.md
- profsnuggles 11y agoThis 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.
- mih 11y agoInteresting approach! Think you can provide us with a small working example, especially the 'deploy' part?
- profsnuggles 11y agoThis 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
- mih 11y agoThanks. 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.