From 6e8881b9ee84e5f97ecba3e844c0dfaed00b68ca Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Sat, 1 Oct 2022 21:02:01 -0400 Subject: [PATCH] Update tools and cache aws profile setting --- chezmoi/dot_tool-versions | 4 ++-- chezmoi/dot_zshrc.d/executable_aws.zsh | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chezmoi/dot_tool-versions b/chezmoi/dot_tool-versions index c1f4b37..7b2d415 100644 --- a/chezmoi/dot_tool-versions +++ b/chezmoi/dot_tool-versions @@ -1,3 +1,3 @@ -golang 1.19 -chezmoi 2.20.0 +golang 1.19.1 +chezmoi 2.23.0 nodejs lts diff --git a/chezmoi/dot_zshrc.d/executable_aws.zsh b/chezmoi/dot_zshrc.d/executable_aws.zsh index 3d117d7..387b775 100644 --- a/chezmoi/dot_zshrc.d/executable_aws.zsh +++ b/chezmoi/dot_zshrc.d/executable_aws.zsh @@ -2,6 +2,11 @@ if command -v aws_completer &> /dev/null; then complete -C "$(command -v aws_completer)" aws fi +_CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/aws_profile_set" +mkdir -p "${_CACHE_DIR}" + +_PREVIOUS_AWS_PROFILE_FILE="${_CACHE_DIR}/last_set_value" + aws_profile_set() { local AWS_CONFIG_PATH="${HOME}/.aws/config" if ! [ -r "${AWS_CONFIG_PATH}" ]; then @@ -23,9 +28,14 @@ aws_profile_set() { echo "setting AWS profile to ${PROFILE}" + echo "$PROFILE" > "$_PREVIOUS_AWS_PROFILE_FILE" export AWS_PROFILE="$PROFILE" export _ORIG_PS1="${_ORIG_PS1:-$PS1}" export PS1="🌩 ${AWS_PROFILE}🌩 ${_ORIG_PS1}" } + +if [ -s "$_PREVIOUS_AWS_PROFILE_FILE" ]; then + aws_profile_set "$(<"$_PREVIOUS_AWS_PROFILE_FILE")" < /dev/null &> /dev/null +fi