Add vterm AWS profile switch command and keybinding

Added a new function `vterm-aws-switch-profile` to switch AWS profiles in the current vterm buffer and associated it with the keybinding `C-c a` for quick access. This facilitates easier management of AWS profiles within vterm sessions.
This commit is contained in:
Jeremy Dormitzer 2024-07-24 12:08:14 -04:00
parent 8ad4c70070
commit 0973393714

View File

@ -28,6 +28,15 @@
(vterm-send-string (format "export AWS_PROFILE=%s\n" profile))) (vterm-send-string (format "export AWS_PROFILE=%s\n" profile)))
(setq aws-current-profile profile)) (setq aws-current-profile profile))
(defun vterm-aws-switch-profile (profile)
"Switch the AWS profile for the current vterm command."
(interactive (list (completing-read "Profile: " (aws-list-profiles))))
(vterm-send-C-a)
(vterm-send-string (format "AWS_PROFILE=%s " profile)))
(with-eval-after-load 'vterm
(define-key vterm-mode-map (kbd "C-c a") #'vterm-aws-switch-profile))
(defun aws-sso-login () (defun aws-sso-login ()
(interactive) (interactive)
(let ((buffer "*aws-sso-login*")) (let ((buffer "*aws-sso-login*"))