Handle AWS SSO login buffer cleanup

Added process sentinel to close the *aws-sso-login* buffer when the AWS SSO login process finishes
This commit is contained in:
Jeremy Dormitzer 2024-07-24 10:40:08 -04:00
parent f9b49ef7b6
commit 77138e6dc9

View File

@ -30,7 +30,16 @@
(defun aws-sso-login () (defun aws-sso-login ()
(interactive) (interactive)
(async-shell-command "AWS_PROFILE=default aws sso login")) (let ((buffer "*aws-sso-login*"))
(async-shell-command "AWS_PROFILE=default aws sso login" buffer)
(with-current-buffer buffer
(let ((proc (get-buffer-process (current-buffer))))
(set-process-sentinel
proc
(lambda (proc sentinel)
(when (string-match-p "finished" sentinel)
(with-selected-window (get-buffer-window (process-buffer proc) t)
(quit-window)))))))))
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
(lambda () (lambda ()