From 9139d30ca30f8f687cc21121ed9b4f5238bc5260 Mon Sep 17 00:00:00 2001 From: Roeniss Moon Date: Wed, 19 Apr 2023 22:46:10 +0900 Subject: [PATCH] feat(aws): allow more customisation in prompt function (#11619) --- plugins/aws/README.md | 2 ++ plugins/aws/aws.plugin.zsh | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 54bc7a44d..9e1e055b8 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -58,6 +58,8 @@ the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control * ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`. +* ZSH_THEME_AWS_DIVIDER: sets the divider between ZSH_THEME_AWS_PROFILE_SUFFIX and ZSH_THEME_AWS_REGION_PREFIX. Defaults to ` ` (single space). + ## Configuration [Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index d45abba57..0da91bc22 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -223,13 +223,16 @@ compctl -K _aws_profiles asp acp aws_change_access_key function aws_prompt_info() { local _aws_to_show local region="${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}" + if [[ -n $AWS_PROFILE ]];then - _aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX:=}" + _aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX=""}" fi + if [[ -n $AWS_REGION ]]; then - [[ -n $AWS_PROFILE ]] && _aws_to_show+=" " - _aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX:=}" + [[ -n $AWS_PROFILE ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=' '}" + _aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX=""}" fi + echo "$_aws_to_show" }