From 6e87ae87b41f01b7ba29a07eb05dd6216ed330a6 Mon Sep 17 00:00:00 2001 From: lamhaison Date: Mon, 3 Apr 2023 17:44:55 +0700 Subject: [PATCH] [Update] - update readme to fix installing instructions and add validate for aws history commandline function --- README.md | 20 +++++++++++++++++--- services/help.sh | 20 ++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cceccdc..78839e7 100755 --- a/README.md +++ b/README.md @@ -48,15 +48,29 @@ echo "random_string" > ~/.password_assume_role_encrypted ## Settings when open terminal (I am using iterm) ``` -mkdir -p /opt/lamhaison-tools && cd /opt/lamhaison-tools +sudo mkdir -p /opt/lamhaison-tools +chown $(whoami) /opt/lamhaison-tools +cd /opt/lamhaison-tools +# If you using ~/.bashrc # Install helpful-commandlines -git clone git@github.com:lamhaison/helpful-commandlines.git +git clone https://github.com/lamhaison/helpful-commandlines.git echo "source /opt/lamhaison-tools/helpful-commandlines/main.sh" >> ~/.bashrc # Install aws-cli-utils commandlines -git clone https://github.com/lamhaison/helpful-commandlines.git +git clone https://github.com/lamhaison/aws-cli-utils.git echo "source /opt/lamhaison-tools/aws-cli-utils/main.sh" >> ~/.bashrc + + +# If using zsh +# Install helpful-commandlines +git clone https://github.com/lamhaison/helpful-commandlines.git +echo "source /opt/lamhaison-tools/helpful-commandlines/main.sh" >> ~/.zshrc + +# Install aws-cli-utils commandlines +git clone https://github.com/lamhaison/aws-cli-utils.git +echo "source /opt/lamhaison-tools/aws-cli-utils/main.sh" >> ~/.zshrc + ``` ## Setting AWS credentials diff --git a/services/help.sh b/services/help.sh index 5dbb6f1..ad52222 100644 --- a/services/help.sh +++ b/services/help.sh @@ -5,15 +5,23 @@ aws_history() { local log_file_path=${aws_cli_logs}/${ASSUME_ROLE}.log local peco_command="cat ${log_file_path} | grep 'Running commandline ' | sed 's/Running commandline //' | uniq" local peco_input=$(peco_create_menu "${peco_command}" '--prompt "Choose aws cli history >"') - # Remove space - peco_input=${peco_input:2} - # To cut ] in the end - peco_input=${peco_input%\]} - local BUFFER=$peco_input - CURSOR=$#BUFFER + if [[ $? -ne 0 ]]; then + return + fi + + if [ ! -z "$peco_input" ]; then + # Remove space + peco_input=${peco_input:2} + # To cut ] in the end + peco_input=${peco_input%\]} + local BUFFER=$peco_input + CURSOR=$#BUFFER + + fi } + aws_help() { local aws_assume_role_main_function="aws_assume_role_set_name_with_hint" local function_list=$(