tools/password-store: improve ivy support (#103)
+ Removed +pass/find & +pass/browse. + Added +pass/open (delegates to +pass/ivy, helm-pass or pass, depending). + Added +pass/ivy with copy password/username, open url and edit entry actions.
This commit is contained in:
parent
20cd13c572
commit
0047baf15c
2 changed files with 42 additions and 7 deletions
|
@ -1,13 +1,40 @@
|
||||||
;;; tools/password-store/autoload.el -*- lexical-binding: t; -*-
|
;;; tools/password-store/autoload.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +pass/find ()
|
(defun +pass/open ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((default-directory (expand-file-name "~/.password-store")))
|
(cond ((featurep! :completion ivy)
|
||||||
(call-interactively #'projectile-find-file)))
|
(+pass-ivy))
|
||||||
|
((featurep! :completion helm)
|
||||||
|
(helm-pass))
|
||||||
|
(t
|
||||||
|
(pass))))
|
||||||
|
|
||||||
|
|
||||||
|
(after! ivy
|
||||||
|
(defun +pass-ivy-action--copy-username (item)
|
||||||
|
(if-let (user (cl-loop with data = '((secret . "rack-quadrant-nay") ("login" . "HL2253-GANDI") ("alt-login" . "hlissner") ("url" . "https://www.gandi.net/login"))
|
||||||
|
for key in +pass-user-fields
|
||||||
|
when (assoc key data)
|
||||||
|
return (cdr it)))
|
||||||
|
(progn (password-store-clear)
|
||||||
|
(message "Copied username to the kill ring.")
|
||||||
|
(kill-new user))
|
||||||
|
(message "Username not found!")))
|
||||||
|
|
||||||
|
(ivy-add-actions
|
||||||
|
'+pass/ivy
|
||||||
|
'(("o" password-store-copy "copy password")
|
||||||
|
("u" +pass-ivy-action--copy-username "copy username")
|
||||||
|
("e" password-store-edit "edit entry")
|
||||||
|
("b" password-store-url "open url in browser"))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +pass/browse ()
|
(defun +pass/ivy (&optional browse-url)
|
||||||
(interactive)
|
(interactive "P")
|
||||||
(let ((default-directory (expand-file-name "~/.password-store")))
|
(ivy-read "Pass: " (password-store-list)
|
||||||
(call-interactively #'find-file)))
|
:action (if browse-url
|
||||||
|
#'password-store-url
|
||||||
|
#'password-store-copy)
|
||||||
|
:caller '+pass/ivy))
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
;;; tools/password-store/config.el -*- lexical-binding: t; -*-
|
;;; tools/password-store/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
(defvar +pass-user-fields '("login" "user" "username" "email")
|
||||||
|
"A list of fields for `+pass/ivy' to search for the username.")
|
||||||
|
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; Plugins
|
||||||
|
;;
|
||||||
|
|
||||||
(def-package! password-store
|
(def-package! password-store
|
||||||
:config
|
:config
|
||||||
(setq password-store-password-length 12))
|
(setq password-store-password-length 12))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue