This repository has been archived by the owner on Jun 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
helm-pass.el
85 lines (67 loc) · 2.8 KB
/
helm-pass.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;;; helm-pass.el --- helm interface of pass, the standard Unix password manager -*- lexical-binding: t; -*-
;; Copyright (C) 2016--2018 J. Alexander Branham
;; Author: J. Alexander Branham <[email protected]>
;; Maintainer: J. Alexander Branham <[email protected]>
;; URL: https://github.com/jabranham/helm-pass
;; Version: 0.2
;; Package-Requires: ((emacs "24.3") (helm "0") (password-store "0") (auth-source-pass "4.0.0"))
;; This file is not part of GNU Emacs.
;;; License:
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see
;; <http://www.gnu.org/licenses/>
;;; Commentary:
;; Emacs helm interface for pass, the standard Unix password manager
;; Users of helm-pass may also be interested in functionality provided by other Emacs packages dealing with pass:
;; password-store.el (which helm-pass relies on): https://git.zx2c4.com/password-store/tree/contrib/emacs/password-store.el
;; pass.el (a major mode for pass): https://github.com/NicolasPetton/pass
;; auth-source-pass.el (integration of Emacs' auth-source with pass, included in Emacs 26+): https://github.com/DamienCassou/auth-password-store
;; Usage:
;; (require 'helm-pass)
;;
;;; Code:
(require 'helm)
(require 'password-store)
(require 'auth-source-pass)
(defgroup helm-pass nil
"Emacs helm interface for helm-pass"
:group 'helm)
(defun helm-pass-get-username (entry)
"Get username for ENTRY.
Does not clear it from clipboard."
(let ((username (auth-source-pass-get "user" entry)))
(if username
(progn (password-store-clear)
(kill-new username))
(message "Username not found!"))))
(defcustom helm-pass-actions
'(("Copy password to clipboard" . password-store-copy)
("Copy username to clipboard" . helm-pass-get-username)
("Edit entry" . password-store-edit)
("Browse url of entry" . password-store-url))
"List of actions for `helm-pass'."
:group 'helm-pass
:type '(alist :key-type string :value-type function))
(defvar helm-pass-source-pass
(helm-build-sync-source "Password File"
:candidates #'password-store-list
:action helm-pass-actions))
;;;###autoload
(defun helm-pass ()
"Helm interface for pass."
(interactive)
(helm :sources 'helm-pass-source-pass
:buffer "*helm-pass*"))
(provide 'helm-pass)
;;; helm-pass.el ends here