mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-22 18:38:00 +00:00
[aws] Update prompt
This commit is contained in:
parent
775f6123b2
commit
c7ef9c1f46
@ -7,19 +7,26 @@
|
|||||||
|
|
||||||
local profile_format
|
local profile_format
|
||||||
local profile_formatted
|
local profile_formatted
|
||||||
|
local aws_prompt
|
||||||
|
local aws_region_prompt
|
||||||
|
|
||||||
unset aws_info
|
unset aws_info
|
||||||
typeset -gA aws_info
|
typeset -gA aws_info
|
||||||
|
|
||||||
|
if (( ${+AWS_SECRET_ACCESS_KEY} )); then
|
||||||
|
aws_prompt='ACCESS_KEY'
|
||||||
|
elif (( ${+AWS_PROFILE} )); then
|
||||||
|
aws_prompt=$AWS_PROFILE
|
||||||
|
|
||||||
if (( ${+AWS_PROFILE} )); then
|
if (( ${+AWS_DEFAULT_REGION} )) && [[ ${_aws_region} = "true" ]]; then
|
||||||
if (( ${+AWS_DEFAULT_REGION} )) && [[ ${_aws_region} = "true" ]]; then
|
AWS_REGION=$(cut -d "-" -f 1 <<<$AWS_DEFAULT_REGION | cut -b 1)$(cut -d "-" -f 2 <<<$AWS_DEFAULT_REGION | cut -b 1)$(cut -d "-" -f 3 <<<$AWS_DEFAULT_REGION | cut -b 1)
|
||||||
AWS_REGION=$(cut -d "-" -f 1 <<<$AWS_DEFAULT_REGION | cut -b 1)$(cut -d "-" -f 2 <<<$AWS_DEFAULT_REGION | cut -b 1)$(cut -d "-" -f 3 <<<$AWS_DEFAULT_REGION | cut -b 1)
|
aws_region_prompt=" $AWS_REGION"
|
||||||
AWS_REGION_PROMPT=" $AWS_REGION"
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if (( ${+AWS_SECRET_ACCESS_KEY} )) || (( ${+AWS_DEFAULT_REGION} )); then
|
||||||
zstyle -s ':prezto:module:aws:info:profile' format 'profile_format'
|
zstyle -s ':prezto:module:aws:info:profile' format 'profile_format'
|
||||||
zformat -f profile_formatted "$profile_format" "v:${AWS_PROFILE:t}${AWS_REGION_PROMPT}"
|
zformat -f profile_formatted "$profile_format" "v:${aws_prompt:t}${aws_region_prompt}"
|
||||||
aws_info[profile]="$profile_formatted"
|
aws_info[profile]="$profile_formatted"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -154,6 +154,7 @@ function aws_switch_profile {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Activating profile $1..."
|
echo "Activating profile $1..."
|
||||||
|
unset -m "AWS_*"
|
||||||
export AWS_PROFILE=$1
|
export AWS_PROFILE=$1
|
||||||
if [[ -f ~/.aws/credentials ]]; then #&& (( ! ${+AWS_DEFAULT_REGION} ))
|
if [[ -f ~/.aws/credentials ]]; then #&& (( ! ${+AWS_DEFAULT_REGION} ))
|
||||||
region=$(aws configure get region)
|
region=$(aws configure get region)
|
||||||
@ -167,6 +168,5 @@ function aws_switch_profile {
|
|||||||
|
|
||||||
function aws_deactivate_profile {
|
function aws_deactivate_profile {
|
||||||
echo "Deactivating aws profile..."
|
echo "Deactivating aws profile..."
|
||||||
unset AWS_PROFILE
|
unset -m "AWS_*"
|
||||||
unset AWS_DEFAULT_REGION
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user