|
@@ -439,3 +439,36 @@ Always open the result in `eww`."
|
|
|
|
|
|
|
|
;; Bind globally to C-c l
|
|
;; Bind globally to C-c l
|
|
|
(global-set-key (kbd "C-c l") #'life-scrobble-url)
|
|
(global-set-key (kbd "C-c l") #'life-scrobble-url)
|
|
|
|
|
+
|
|
|
|
|
+(after! magit
|
|
|
|
|
+ (defvar my/ssh-key-injector-script
|
|
|
|
|
+ (expand-file-name "~/.local/bin/inject-ssh-keys-from-pass"))
|
|
|
|
|
+
|
|
|
|
|
+ (defun my/ssh-agent-has-keys-p (&rest _ignore)
|
|
|
|
|
+ "Non-nil if ssh-agent currently has at least one identity loaded."
|
|
|
|
|
+ (eq 0 (call-process "ssh-add" nil nil nil "-l")))
|
|
|
|
|
+
|
|
|
|
|
+ (defun my/ensure-ssh-keys-loaded (&rest _ignore)
|
|
|
|
|
+ "Ensure ssh-agent has keys loaded; if not, run injector script."
|
|
|
|
|
+ (unless (my/ssh-agent-has-keys-p)
|
|
|
|
|
+ (unless (file-executable-p my/ssh-key-injector-script)
|
|
|
|
|
+ (user-error "SSH injector script not executable: %s" my/ssh-key-injector-script))
|
|
|
|
|
+ (let ((buf (get-buffer-create "*ssh-key-injector*")))
|
|
|
|
|
+ (with-current-buffer buf (erase-buffer))
|
|
|
|
|
+ (let ((exit (call-process-shell-command my/ssh-key-injector-script nil buf t)))
|
|
|
|
|
+ (unless (eq exit 0)
|
|
|
|
|
+ (display-buffer buf)
|
|
|
|
|
+ (user-error "SSH key injection failed (see *ssh-key-injector*)"))))))
|
|
|
|
|
+
|
|
|
|
|
+ ;; IMPORTANT: remove then re-add, so we don't keep an old advised function object around
|
|
|
|
|
+ (advice-remove 'magit-status #'my/ensure-ssh-keys-loaded)
|
|
|
|
|
+ (advice-add 'magit-status :before #'my/ensure-ssh-keys-loaded)
|
|
|
|
|
+
|
|
|
|
|
+ ;; optional:
|
|
|
|
|
+ (advice-remove 'magit-fetch #'my/ensure-ssh-keys-loaded)
|
|
|
|
|
+ (advice-add 'magit-fetch :before #'my/ensure-ssh-keys-loaded)
|
|
|
|
|
+ (advice-remove 'magit-push #'my/ensure-ssh-keys-loaded)
|
|
|
|
|
+ (advice-add 'magit-push :before #'my/ensure-ssh-keys-loaded)
|
|
|
|
|
+ (advice-remove 'magit-pull #'my/ensure-ssh-keys-loaded)
|
|
|
|
|
+ (advice-add 'magit-pull :before #'my/ensure-ssh-keys-loaded))
|
|
|
|
|
+
|