Created
April 17, 2015 18:36
-
-
Save kenmanheimer/bc03f06dbe06a4c9fd28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-get-agent () | |
"Establish my registered ssh agent in this emacs shell *and* emacs session." | |
(interactive) | |
(let ((process (get-buffer-process (current-buffer))) | |
beg end start-point) | |
(if (not process) | |
(error "Non-shell buffer") | |
(goto-char (process-mark process)) | |
(insert "eval $(ga); echo SSH_AUTH_SOCK::$SSH_AUTH_SOCK::") | |
(comint-send-input) | |
(setq start-point (point)) | |
(let ((tries 0) | |
got) | |
(while (not got) | |
(sleep-for .25) | |
(goto-char (point-max)) | |
(setq tries (1+ tries)) | |
(if (> tries 40) | |
(error "Failed to find agent socket id after 10 seconds")) | |
(when (re-search-backward "SSH_AUTH_SOCK::\\(.*\\)::" start-point t) | |
(setq got (buffer-substring (match-beginning 1) (match-end 1))) | |
(setenv "SSH_AUTH_SOCK" got) | |
(goto-char (process-mark process)) | |
(message "SSH_AUTH_SOCK: %s" (getenv "SSH_AUTH_SOCK")))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment