Created
June 6, 2017 18:03
-
-
Save robbintt/5e93b8eb5b324483cae8196e5854e17b to your computer and use it in GitHub Desktop.
Zephyr / zv wrote this after save encrypt hook for encrypting stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Zephyr / zv wrote this after save encrypt hook for encrypting stuff | |
(defun zv/encrypt-secrets () | |
"Encrypt this file if it is in one of our `dirs-to-encrypt'" | |
(require 'epa-mail) | |
(let* ((zv-dotfiles (expand-file-name "~/Development/dotfilez/")) | |
(files-to-encrypt (list (expand-file-name "~/.authinfo"))) | |
(dirs-to-encrypt (list (expand-file-name "~/.gnupg") | |
(expand-file-name (concat org-directory "/")) | |
(concat zv-dotfiles "gnupg/") | |
(concat zv-dotfiles "ssh/") | |
(expand-file-name "~/.ssh/"))) | |
(recipient (epg-list-keys (epg-make-context epa-protocol) "<zv@nxvr.org>" 'public))) | |
(when (or (member (file-name-directory (buffer-file-name)) dirs-to-encrypt) (member buffer-file-name files-to-encrypt)) | |
(epa-encrypt-file (buffer-file-name) recipient)))) | |
;; Turn on encrypt hook | |
(add-hook 'after-save-hook 'zv/encrypt-secrets) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment