summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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