summaryrefslogtreecommitdiff
path: root/jakob.org
diff options
context:
space:
mode:
authorJakob L. Kreuze2019-03-11 18:50:28 -0400
committerJakob L. Kreuze2019-03-11 18:50:28 -0400
commite730f0412336fa7d39661373e61735af9993de2f (patch)
treef030b368546e39ec432c09e91819f54ad7ce0d07 /jakob.org
parent8da439e6e0b95c0e710474c07f0861a8041a2bc5 (diff)
Add an Emacs interface to .password-store
Diffstat (limited to 'jakob.org')
-rw-r--r--jakob.org26
1 files changed, 26 insertions, 0 deletions
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

© 2015 - 2026 Jakob L. Kreuze