From e730f0412336fa7d39661373e61735af9993de2f Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Mon, 11 Mar 2019 18:50:28 -0400 Subject: Add an Emacs interface to .password-store --- jakob.org | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'jakob.org') diff --git a/jakob.org b/jakob.org index 36d8425..4b7d514 100644 --- a/jakob.org +++ b/jakob.org @@ -353,6 +353,32 @@ Set up keybindings for =imenu=. :bind ("C-c s" . imenu)) #+END_SRC +** pass + +#+BEGIN_SRC elisp +(defvar password-store-directory "~/.password-store" + "Directory containing passwords managed by `pass'.") + +(defun pass-password-files () + "Returns the paths of every password managed by `pass'." + (let ((prefix-length (1+ (length (expand-file-name password-store-directory)))) + (suffix-length (length ".gpg"))) + (map 'list + #'(lambda (path) (subseq path prefix-length (- suffix-length))) + (directory-files-recursively password-store-directory ".gpg$")))) + +(defun pass () + "Prompt for a password and copy it to the clipboard. +Passwords are taken from `password-store-directory'." + (interactive) + (let* ((account (completing-read "Account: " (pass-password-files))) + (path (concat password-store-directory "/" account ".gpg"))) + (with-temp-buffer + (insert-file path) + (clipboard-kill-ring-save 1 (1- (buffer-end 1)))) + (message "Password for %s copied to clipboard." account))) +#+END_SRC + * Appearance This feature doesn't see frequent use, but I prefer three proportionally-sized -- cgit v1.3