[zsh] Move away from funky SSH key loading

This commit is contained in:
2026-03-04 00:19:29 -05:00
parent 32d1416bb9
commit 28a7b9f65a
2 changed files with 45 additions and 43 deletions

View File

@ -454,45 +454,46 @@ Always open the result in `eww`."
;; Bind globally to C-c l
(global-set-key (kbd "C-c l") #'life-scrobble-url)
(after! magit
(defvar my/ssh-key-injector-script (expand-file-name "~/.local/bin/load_keys"))
(defun my/ssh-add-status ()
(call-process "ssh-add" nil nil nil "-l"))
(defun my/run-ssh-key-injector ()
(my/apply-ssh-agent-env)
(let* ((buf (get-buffer-create "*ssh-key-injector*"))
(process-connection-type t)
(process-environment (copy-sequence process-environment)))
(unless (file-executable-p my/ssh-key-injector-script)
(user-error "SSH injector script not executable: %s" my/ssh-key-injector-script))
(with-current-buffer buf
(erase-buffer)
(insert (format "Emacs SSH_AUTH_SOCK=%s\n\n" (or (getenv "SSH_AUTH_SOCK") "<unset>"))))
(let ((proc (make-process
:name "ssh-key-injector"
:buffer buf
:stderr buf
:command (list my/ssh-key-injector-script)
:noquery t)))
(while (process-live-p proc)
(accept-process-output proc 0.05))
(unless (eq (process-exit-status proc) 0)
(display-buffer buf)
(user-error "SSH key injection failed. See *ssh-key-injector*.")))))
(defun my/ensure-ssh-keys-loaded (&rest _ignore)
(pcase (my/ssh-add-status)
(0 nil)
(1 (my/run-ssh-key-injector))
(2 (user-error "No reachable ssh-agent (SSH_AUTH_SOCK=%s)"
(or (getenv "SSH_AUTH_SOCK") "<unset>")))
(_ (my/run-ssh-key-injector))))
(dolist (fn '(magit-status magit-fetch magit-push magit-pull))
(advice-remove fn #'my/ensure-ssh-keys-loaded)
(advice-add fn :before #'my/ensure-ssh-keys-loaded)))
; (after! magit
; (defvar my/ssh-key-injector-script (expand-file-name "~/.local/bin/load_keys"))
;
; (defun my/ssh-add-status ()
; (call-process "ssh-add" nil nil nil "-l"))
;
; (defun my/run-ssh-key-injector ()
; (my/apply-ssh-agent-env)
; (let* ((buf (get-buffer-create "*ssh-key-injector*"))
; (process-connection-type t)
; (process-environment (copy-sequence process-environment)))
; (unless (file-executable-p my/ssh-key-injector-script)
; (user-error "SSH injector script not executable: %s" my/ssh-key-injector-script))
; (with-current-buffer buf
; (erase-buffer)
; (insert (format "Emacs SSH_AUTH_SOCK=%s\n\n" (or (getenv "SSH_AUTH_SOCK") "<unset>"))))
; (let ((proc (make-process
; :name "ssh-key-injector"
; :buffer buf
; :stderr buf
; :command (list my/ssh-key-injector-script)
; :noquery t)))
; (while (process-live-p proc)
; (accept-process-output proc 0.05))
; (unless (eq (process-exit-status proc) 0)
; (display-buffer buf)
; (user-error "SSH key injection failed. See *ssh-key-injector*.")))))
;
; (defun my/ensure-ssh-keys-loaded (&rest _ignore)
; (pcase (my/ssh-add-status)
; (0 nil)
; (1 (my/run-ssh-key-injector))
; (2 (user-error "No reachable ssh-agent (SSH_AUTH_SOCK=%s)"
; (or (getenv "SSH_AUTH_SOCK") "<unset>")))
; (_ (my/run-ssh-key-injector))))
;
; (dolist (fn '(magit-status magit-fetch magit-push magit-pull))
; (advice-remove fn #'my/ensure-ssh-keys-loaded)
; (advice-add fn :before #'my/ensure-ssh-keys-loaded)))
(defun my/disable-apheleia-in-certain-projects ()
(when-let ((root (and (fboundp 'project-root)

View File

@ -3,14 +3,17 @@ export GOPATH="$HOME/.go"
export PATH=$HOME/.bin:$HOME/var/bin:/usr/local/bin:$PATH:$HOME/.go/bin:$HOME/.local/bin
export GIT_CU_DIR="$HOME/src"
export ZSH="$HOME/.oh-my-zsh"
export GPG_TTY=$(tty)
export SSH_ASKPASS="$HOME/.local/bin/ssh-askpass-load-keys"
export SSH_ASKPASS_REQUIRE=force
#load_keys &>/dev/null
ZSH_THEME="robbyrussell"
plugins=(git z fzf asdf direnv emacs yarn aws)
eval "$($HOME/.local/bin/ssh-agent-env)"
load_keys &>/dev/null
source $ZSH/oh-my-zsh.sh
create_email() {
@ -61,10 +64,8 @@ esac
[[ -d "/home/linuxbrew/.linuxbrew/bin" ]] && export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH
eval "$(direnv hook /bin/zsh)"
export GPG_TTY=$(tty)
. ${ASDF_DATA_DIR:-$HOME/.asdf}/plugins/golang/set-env.zsh &>/dev/null
load_keys &>/dev/null
# opencode
[[ -d "$HOME/.npm-global" ]] && export PATH="$HOME/.npm-global/bin":$PATH