diff options
| author | Jakob L. Kreuze | 2019-03-11 18:50:28 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2019-03-11 18:50:28 -0400 |
| commit | e730f0412336fa7d39661373e61735af9993de2f (patch) | |
| tree | f030b368546e39ec432c09e91819f54ad7ce0d07 | |
| parent | 8da439e6e0b95c0e710474c07f0861a8041a2bc5 (diff) | |
Add an Emacs interface to .password-store
| -rw-r--r-- | jakob.org | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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 |