Skip to content

Commit 46eb1dc

Browse files
committed
[Refactor] - to allow to add args for load source instead of getting from dirname directory
1 parent fc13c43 commit 46eb1dc

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

main.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
# Get the current directory of the main.sh script.
2-
export AWS_CLI_SOURCE_SCRIPTS="$(dirname -- "$0")"
1+
#!/bin/bash
2+
#
3+
# @version 1.0
4+
# @script main.sh
5+
# @description TODO : to load function for aws-cli-utils
6+
# $1: Where is looking for sh files and source the list
7+
# $2: Do you want to set the bind key?
8+
9+
AWS_CLI_SOURCE_SCRIPTS=$1
10+
11+
if [[ -z "${AWS_CLI_SOURCE_SCRIPTS}" ]]; then
12+
LOCAL_AWS_CLI_SOURCE_SCRIPTS=$(dirname -- "$0")
13+
if [[ "${LOCAL_AWS_CLI_SOURCE_SCRIPTS}" = "." ]]; then
14+
DEFAULT_AWS_CLI_SOURCE_SCRIPTS='/opt/lamhaison-tools/aws-cli-utils'
15+
fi
16+
17+
export AWS_CLI_SOURCE_SCRIPTS="${LOCAL_AWS_CLI_SOURCE_SCRIPTS:=${DEFAULT_AWS_CLI_SOURCE_SCRIPTS}}"
18+
else
19+
export AWS_CLI_SOURCE_SCRIPTS=${AWS_CLI_SOURCE_SCRIPTS}
20+
fi
321

422
export assume_role_password_encrypted="$(cat ~/.password_assume_role_encrypted)"
523
export tmp_credentials="/tmp/aws_temporary_credentials"
@@ -36,7 +54,7 @@ alias get-account-alias='aws iam list-account-aliases'
3654
alias get-account-id='echo AccountId $(aws sts get-caller-identity --query "Account" --output text)'
3755

3856
# Import sub-commandlines.
39-
for script in $(find ${AWS_CLI_SOURCE_SCRIPTS} -type f -name '*.sh' | grep -v main.sh); do
57+
for script in $(find ${AWS_CLI_SOURCE_SCRIPTS} -type f -name '*.sh' | grep -v main.sh | grep -v main.sh | grep -v test.sh | grep -v temp.sh); do
4058
source $script
4159
done
4260

@@ -49,8 +67,12 @@ if [ "true" = "${aws_cli_load_current_assume_role}" ] && [ -s "${aws_cli_current
4967
aws_assume_role_load_current_assume_role_for_new_tab
5068
fi
5169

52-
# Add hot-keys
53-
# zle -N aws_help
54-
zle -N aws_main_function
55-
bindkey '^@' aws_main_function
70+
LHS_BIND_KEY=${2:='True'}
71+
72+
if [[ "${LHS_BIND_KEY}" = "True" ]]; then
73+
# Add hot-keys
74+
# zle -N aws_help
75+
zle -N aws_main_function
76+
bindkey '^@' aws_main_function
5677
# bindkey '^e' aws_help
78+
fi

0 commit comments

Comments
 (0)