7
7
# $2: Where do you want to save logs?
8
8
# $3: Do you want to set the bind key?
9
9
10
+ DEFAULT_AWS_CLI_SOURCE_SCRIPTS=' /opt/lamhaison-tools/aws-cli-utils'
11
+ DEFAULT_AWS_CLI_DATA=' /opt/lamhaison-tools/aws-cli-utils'
12
+
10
13
AWS_CLI_SOURCE_SCRIPTS=$1
11
14
12
15
if [[ -z " ${AWS_CLI_SOURCE_SCRIPTS} " ]]; then
13
16
LOCAL_AWS_CLI_SOURCE_SCRIPTS=$( dirname -- " $0 " )
14
- if [[ " ${LOCAL_AWS_CLI_SOURCE_SCRIPTS} " = " ." ]]; then
15
- DEFAULT_AWS_CLI_SOURCE_SCRIPTS= ' /opt/lamhaison-tools/aws-cli-utils '
17
+ if [[ " ${LOCAL_AWS_CLI_SOURCE_SCRIPTS} " == " ." ]]; then
18
+ LOCAL_AWS_CLI_SOURCE_SCRIPTS= " ${DEFAULT_AWS_CLI_SOURCE_SCRIPTS} "
16
19
fi
17
20
18
21
export AWS_CLI_SOURCE_SCRIPTS=" ${LOCAL_AWS_CLI_SOURCE_SCRIPTS:- ${DEFAULT_AWS_CLI_SOURCE_SCRIPTS} } "
23
26
AWS_CLI_DATA=$2
24
27
if [[ -z " ${AWS_CLI_DATA} " ]]; then
25
28
LOCAL_AWS_CLI_DATA=$( dirname -- " $0 " )
26
- if [[ " ${LOCAL_AWS_CLI_DATA} " = " ." ]]; then
27
- DEFAULT_AWS_CLI_DATA= ' /opt/lamhaison-tools/aws-cli-utils '
29
+ if [[ " ${LOCAL_AWS_CLI_DATA} " == " ." ]]; then
30
+ LOCAL_AWS_CLI_DATA= " ${DEFAULT_AWS_CLI_DATA} "
28
31
fi
29
32
30
33
export AWS_CLI_DATA=" ${LOCAL_AWS_CLI_DATA:- ${DEFAULT_AWS_CLI_DATA} } "
31
34
else
32
35
export AWS_CLI_DATA=${AWS_CLI_DATA}
33
36
fi
34
37
38
+ # shellcheck disable=SC2155
35
39
export assume_role_password_encrypted=" $( cat ~ /.password_assume_role_encrypted) "
36
40
export tmp_credentials=" /tmp/aws_temporary_credentials"
37
41
@@ -67,20 +71,20 @@ mkdir -p ${aws_cli_list_commands_folder}
67
71
export AWS_DEFAULT_OUTPUT=" json"
68
72
69
73
# add some help aliases
70
- alias get-account-alias=' aws iam list-account-aliases'
74
+ alias get-account-alias=' aws iam list-account-aliases --query "*[0]" --output text '
71
75
alias get-account-id=' echo AccountId $(aws sts get-caller-identity --query "Account" --output text)'
72
76
73
77
# Import sub-commandlines.
74
78
for script in $(
75
79
find ${AWS_CLI_SOURCE_SCRIPTS} -type f -name ' *.sh' |
76
- grep -v main.sh | grep -v main.sh | grep -v test.sh | grep -v temp.sh | grep -v aws-cli-utils.sh
80
+ grep -v -E ' .*( main.sh| test.sh| temp.sh| aws-cli-utils.sh)$ '
77
81
) ; do
78
82
source $script
79
83
done
80
84
81
85
# Reuse session in the new terminal
82
86
export aws_cli_current_assume_role_name=" /tmp/aws_cli_current_assume_role_SW7DNb48oQB57"
83
- export aws_cli_load_current_assume_role=false
87
+ export aws_cli_load_current_assume_role=true
84
88
# If the file is not empty
85
89
# TODO Later (To check if the credential is expired, don't autoload credential)
86
90
if [ " true" = " ${aws_cli_load_current_assume_role} " ] && [ -s " ${aws_cli_current_assume_role_name} " ]; then
89
93
90
94
LHS_BIND_KEY=${3:- ' True' }
91
95
92
- if [[ " ${LHS_BIND_KEY} " = " True" ]]; then
96
+ if [[ ${LHS_BIND_KEY} == " True" && " $( which zle ) " != " " ]]; then
93
97
# Add hot-keys
94
98
# zle -N aws_help
95
99
zle -N aws_main_function
@@ -99,6 +103,8 @@ if [[ "${LHS_BIND_KEY}" = "True" ]]; then
99
103
# Hotkey: Option + a + c
100
104
bindkey ' åç' aws_get_command
101
105
106
+ bindkey ' ∫' aws_get_command
107
+
102
108
zle -N aws_history
103
109
# Hotkey Option + ah
104
110
bindkey ' ˙' aws_history
0 commit comments