From cc6f013282a84d81d6cdb5c82e57da59c49c6898 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 23 Apr 2019 10:26:31 -0400 Subject: [PATCH] Add 1pass-signin command --- emacs/init.org | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/emacs/init.org b/emacs/init.org index 8c5b588..e219225 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -2773,3 +2773,30 @@ The aws-mfa command: (general-def kubernetes-overview-mode-map "m" #'aws-mfa)) #+END_SRC +** 1Password +#+BEGIN_SRC emacs-lisp + (defvar op-token nil + "The 1Password session token") + + (defun 1pass-signin () + (interactive) + (let* ((signin-address "team-lolatravel.1password.com") + (signin-email "jeremydormitzer@lola.com") + (secret-key (password-store-get "1pass-lola-secret-key")) + (master-password (password-store-get "team-lolatravel.1password.com")) + (proc (start-process "op-signin" "*op-signin*" + "op" "signin" signin-address signin-email secret-key "--output=raw"))) + (set-process-sentinel + proc + (make-process-sentinel + (lambda () + (setq op-token + (with-current-buffer "*op-signin*" + (goto-char (- (point-max) 1)) + (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) + (message (format "Signed in to 1Password with session token %s" op-token)) + (kill-buffer "*op-signin*")) + (lambda () + (message "1Password signin failed, check *op-signin* buffer for details")))) + (process-send-string proc (concat master-password "\n")))) +#+END_SRC