From 0973393714ed275a496fb80d6c55ad459014fcc0 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 24 Jul 2024 12:08:14 -0400 Subject: [PATCH] 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. --- emacs/.emacs.d/config/init-aws.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/emacs/.emacs.d/config/init-aws.el b/emacs/.emacs.d/config/init-aws.el index 8b1d16d..0337446 100644 --- a/emacs/.emacs.d/config/init-aws.el +++ b/emacs/.emacs.d/config/init-aws.el @@ -28,6 +28,15 @@ (vterm-send-string (format "export AWS_PROFILE=%s\n" 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 () (interactive) (let ((buffer "*aws-sso-login*"))