Parcourir la source

BAK ##2026-05-12T08:45:49+0200

Diller, Jan il y a 1 mois
Parent
commit
5894bd438c
7 fichiers modifiés avec 827 ajouts et 0 suppressions
  1. 0 0
      .gitkeep
  2. 4 0
      _bash_rc.txt
  3. 295 0
      bashrc_extension.sh
  4. 69 0
      clouddk
  5. 138 0
      envaws
  6. 144 0
      git
  7. 177 0
      terraform

+ 0 - 0
.gitkeep


+ 4 - 0
_bash_rc.txt

@@ -0,0 +1,4 @@
+
+## ----------------------------------------------------------------------
+
+. ~/.local/bin/bashrc_extension.sh

+ 295 - 0
bashrc_extension.sh

@@ -0,0 +1,295 @@
+#!/bin/bash
+## >>> general
+export PS1='\[\033[1;36m\][\[\033[1;34m\]\u\[\033[1;33m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;36m\]]\[\033[1;31m\]\\$\[\033[0m\] '
+export PATH=~/.tfenv/bin:$PATH
+#export PATH=~/.local/bin:$PATH
+export EDITOR=vim
+export HISTCONTROL=ignoreboth:erasedups
+
+#export PATH=/mnt/c/Users/jan.diller/AppData/Local/Programs/Rancher\ Desktop/resources/resources/linux/bin:$PATH
+
+# ---------------------------------------------------------------------------------------------------
+
+alias       jb='cd "${CC_PATH}"'
+alias       l1='ls -1a'
+alias       qm="xargs -rI{} mv '{}'"
+alias       rr='rm -Rf'
+alias       xi='xsel -bi'
+alias       xo='xsel -bo'
+alias      cls='clear'
+alias      fdg='find . -type d | grep'
+alias      ffg='find . -type f | grep'
+alias      lsd="find . -maxdepth 1 -type d -not -path '*/.terraform*' -not -path '*/.git*'"
+alias     oany='code "$(find -maxdepth 1 -type f | head -n 1)"'
+alias  tickets="xsel -bo | grep -E '^(A|D|M)\s' | rev | cut -d '/' -f 2-99 | rev | cut -d$'\t' -f 2-99 | sort -u"
+alias globTrim="find . -type f -not -path '*/.terraform*' -not -path '*/.git*' | xargs -rI{} sed -i '{}' -e 's|[ ]*$||g'"
+
+function cc(){
+  local cc_path="$(find . -type d -maxdepth 3 -not -path '*/.terraform*' -not -path '*/.git*' 2>/dev/null |  xargs -rI{} bash -c 'echo -e "0\t../../..\n$(echo "{}" | tr -cd '/' | wc -c)\t{}"' | sort -u | cut -d$'\t' -f 2 | grep -Ei "$(echo "$@" | tr -s ' ' | sed -E 's| |\.*|g')" | nl -i1 -n'rz' -v0 -w3 | fzf | cut -d$'\t' -f 2)"
+  cc_path="${PWD}/${cc_path}"
+  export CC_PATH="${cc_path}"
+  cd "${CC_PATH}";
+}
+
+function cf(){
+  local cc_path="$(find . -type f -maxdepth 4 -not -path '*/.terraform*' -not -path '*/.git*' 2>/dev/null |  xargs -rI{} bash -c 'echo -e "0\t../../..\n$(echo "{}" | tr -cd '/' | wc -c)\t{}"' | sort -u | cut -d$'\t' -f 2 | grep -Ei "$(echo "$@" | tr -s ' ' | sed -E 's| |\.*|g')" | nl -i1 -n'rz' -v0 -w3 | fzf | cut -d$'\t' -f 2)"
+  cc_path=$(printf "${cc_path}" | rev | cut -d '/' -f 2-99 | rev)
+  cc_path="${PWD}/${cc_path}"
+  export CC_PATH="${cc_path}"
+  cd "${CC_PATH}";
+}
+
+function ccb(){
+  local cc_file="$(find . -type f -not -path '*/.terraform*' -not -path '*/.git*' 2>/dev/null |  xargs -rI{} bash -c 'echo -e "0\t../../..\n$(echo "{}" | tr -cd '/' | wc -c)\t{}"' | sort -u | cut -d$'\t' -f 2 | grep -Ei "$(echo "$@" | tr -s ' ' | sed -E 's| |\.*|g')" | nl -i1 -n'rz' -v0 -w3 | fzf | cut -d$'\t' -f 2)"
+  cc_file="${PWD}/${cc_file}"
+  printf "'%s'" "${cc_file}" | xsel -bi
+}
+
+function diffho {
+  while  IFS= read res; do
+    local head="${res}"
+    local origin=$(echo "${res}" | sed 's|head|origin|g')
+
+    diff  -x '.git' -ruN "${origin}" "${head}"
+
+  done < <(eval 'ls -1 | grep -E head$ | xargs -rI{} find  '{}'  -type f -not -path '*/.terraform*' -not -path '*/.git*' | sort -u | '"${1}"'')
+}
+
+function logall() {
+  local all="$1"
+  local err="$2"
+  shift 2
+  "$@" > >(tee "$all") 2> >(tee "$err" | tee -a "$all" >&2)
+}
+
+function mh(){
+local opts=$(cat << EOF
+dck    ::   . ______________
+dckab  :q:  docker run -u "$(id -u):$(id -g)" -it  --rm -v "\${PWD}":/documents acdc /bin/bash
+dckar  ::   docker build -t   acdc    ~/dev/docker-doc/head
+dckar  :q:  docker run --rm -u $(id -u):$(id -g) -v $(pwd):/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf '${1}'
+dckst  :q:  sudo /usr/sbin/service docker start
+ecf    ::   . ______________
+ecf    ::   code ~/.aws/config ~/.aws/credentials
+ecf    ::   code ~/.local/bin/bashrc_extension.sh
+ecf    ::   code ~/.local/bin/envaws
+ecf    ::   code ~/.local/bin/git
+ecf    ::   code ~/.local/bin/terraform
+fnd    ::   . ______________
+fnd    ::   find -L . -type f -not -path '*/.terraform*' -not -path '*/.git*' | xargs -rI{} file "{}" | grep ASCII | cut -d ":" -f 1 | xargs -rI{} grep -EH '^' '{}'
+fnd    ::   find . -type f | grep -E '#Untitled.*|\.marks$' | xargs -rI{} rm -v '{}'
+fndac  ::   find -L . -type f -not -path '*/.terraform*' -not -path '*/.git*' | xargs -rI{} file "{}" | grep ASCII | cut -d ":" -f 1 | sort -u --version-sort | xargs -rI{} grep -EH '^' '{}' >../$(pwd | sed -E 's|.*/(.*)|\1_allCnt\.txt|g')
+nxtcld ::   . ______________
+nxtcld :q:   nextcloud >/dev/null 2>&1 &
+oth    ::   . ______________
+oth    ::   . ~/.bashrc
+oth    ::   find -type f | grep -E '\.jr$|plan\.txt|state\.yaml' | xargs rm -f
+oth    :q:  while IFS= read res; do code "\${res}"; done < <(find | grep -F '_overview.adoc' | xargs -rI{} grep -EH '=== done' '{}' | grep '\-\-\-' | cut -d ':' -f 1)
+oth    ::   sed -i -r 's/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g' "${1}"
+oth    ::   vi ~/.local/bin/bashrc_extension.sh
+oth    :q:  cp \$(winpath '${1}') .
+penv   ::   . ______________
+penv   ::   cat ~/.local/env.txt
+rdc    ::   . ______________
+rdc    ::   sudo /etc/init.d/xrdp start
+EOF
+)
+
+  local selOpt=$(echo "${opts}" | grep -vE '^##' | nl -i1 -n'rz' -v0 -w3 | sort -ru | fzf)
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+
+    mode=$( echo "${selOpt}" | sed  -E 's/(^.*)([ ]*)(:[a-z]?:)([ ]*)(.*$)/\3/g' )
+  selOpt=$( echo "${selOpt}" | sed  -E 's/(^.*)([ ]*)(:[a-z]?:)([ ]*)(.*$)/\5/g' )
+
+  case $mode in
+    ":q:")
+      echo ">>>>>>> ${selOpt}"
+      history -s "${selOpt}"
+      eval "${selOpt}"
+      ;;
+    *)
+      echo ">>>>>>> ${selOpt} '$@'"
+      history -s "${selOpt} '$@'"
+      history -s "mh '$@'"
+      eval "${selOpt} '$@'"
+      ;;
+  esac
+}
+
+function ord() {
+  printf "&#%d;" "\"$1";
+}
+
+
+function ppp(){
+local opts=$(cat << EOF
+dcycpbd    :q: xsel -bo | gpg --decrypt | xsel -bi
+dcyfle     :q: $(printf  "gpg --decrypt '%s'" "${1}" )
+dcyfle     :q: $(printf  "gpg --output '%s'  --decrypt '%s'" $(echo "${1}" | rev | cut -d '.' -f 2-99 | rev) "${1}" )
+enccpbd    :q: xsel -bo | gpg --encrypt --armor        --recipient '%s' | xsel -bi
+enccpbdsgn :q: xsel -bo | gpg --encrypt --armor --sign --recipient '%s' | xsel -bi
+encfle     :q: $(printf "gpg --encrypt --armor        --recipient '%%s' '%s'" "${1}")
+encflesgn  :q: $(printf "gpg --encrypt --armor --sign --recipient '%%s' '%s'" "${1}")
+exppbl     :q: $(printf 'gpg --armor --export             %%s >%s.pbl.asc' "${1}" )
+expprv     :q: $(printf 'gpg --armor --export-secret-keys %%s >%s.prv.asc' "${1}" )
+keycrt     :q: gpg --full-generate-key
+keyimp     :q: $(printf 'gpg --import  %s' "${1}" )
+keylst     :q: gpg --list-keys
+keysgn     :q: gpg --sign-key '%s'
+EOF
+)
+
+  local selOpt=$(echo "${opts}" | grep -vE '^##' | nl -i1 -n'rz' -v0 -w3 | sort -ru | fzf)
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+
+  selOpt=$(echo "${selOpt}" | tr '\t' ' ' | tr -s ' ')
+
+    prfx=$( echo "${selOpt}" | cut -d ' ' -f 2     )
+    mode=$( echo "${selOpt}" | cut -d ' ' -f 3     )
+  selOpt=$( echo "${selOpt}" | cut -d ' ' -f 4-999 )
+     swt=$( echo "${prfx:0:3}" )
+     usr=''
+
+  case "${prfx}" in
+    expprv|exppbl|encfle|encflesgn)
+      if [[ -z "$1" ]]; then echo "Fehler: Parameter 1 fehlt" >&2; return 1;   fi;
+      usr=$(echo "$(gpg --list-keys | grep uid | xargs -rI{} echo '{}' | tr -s ' ' | cut -d '<' -f 2 | sed 's/.$//')" | fzf)
+      selOpt=$(printf "${selOpt}" "${usr}")
+      ;;
+    keyimp)
+      if [[ -z "$1" ]]; then echo "Fehler: Parameter 1 fehlt" >&2; return 1;   fi;
+      ;;
+    enccpbd|enccpbdsgn|keysgn)
+      usr=$(echo "$(gpg --list-keys | grep uid | xargs -rI{} echo '{}' | tr -s ' ' | cut -d '<' -f 2 | sed 's/.$//')" | fzf)
+      selOpt=$(printf "${selOpt}" "${usr}")
+      ;;
+    *)
+      ;;
+  esac
+
+  echo "${usr}"
+  echo ">>>>>>> ${selOpt}"
+  eval "${selOpt}"
+}
+
+function qcat {
+  local file=$(find . -type f -not -path '*/.terraform*' -not -path '*/.git*' | grep -iE "${1}" | fzf)
+
+  cmd=$(printf "cat '%s'" "${file}")
+
+  eval "${cmd}"
+}
+
+function qrun {
+  eval $(cat "${1}" | grep -vE '^#' | sort -u | nl -w 3 -n 'rz' | sort -r  | fzf | sed -E 's|^[0-9\t]+||g')
+}
+
+alias qvi='vi "$(find . -type f | fzf)"'
+
+function qcode (){
+  local selOpt=$(eval $(printf "find . -type f -not -path '*/.terraform*' -not -path '*/.git*' | grep -Ev '\.(pem|pub)$' | grep -E '%s' | fzf" "${1:-.*}"))
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+
+  echo ">>>>>>> code ${selOpt}"
+  history -s "code ${selOpt}"
+  eval "code ${selOpt}"
+}
+
+function stack() {
+    local depot="${HOME}/depot"
+
+    if [[ $# -ne 1 ]]; then
+        echo "Usage: stack {pull|push|purge}"
+        return 1
+    fi
+
+    case "$1" in
+        push)
+            echo "Stack: push"
+            src=$(ls -1 | fzf)
+            prfx=$(date +"%Y%m%d%H%M%S")
+            echo ">>> ${prfx}"
+            echo ">>> ${src}"
+            if [[ -n "$src" ]]; then tar -czvf "${depot}/${prfx}_${src}.tgz" "${src}"; fi
+            ;;
+        pull)
+            echo "Stack: pull"
+            src=$(ls -1 "${depot}" | fzf)
+            echo ">>> ${src}"
+            trg=$(echo "${src}" | cut -d '_' -f 2 | rev | cut -d '.' -f 2 | rev)
+            echo ">>> ${trg}"
+            if [[ -n "$src" ]]; then tar -xzvf "${depot}/${src}" --strip-components=1; fi
+            ;;
+        purge)
+            echo "Stack: purge"
+            src=$(ls -1 "${depot}" | fzf)
+            echo ">>> ${src}"
+            if [[ -n "$src" ]]; then rm -Rfv "${depot}/${src}"; fi
+            ;;
+        *)
+            echo "Ungültiger Parameter: $1"
+            return 1
+            ;;
+    esac
+}
+
+function goto(){
+local opts=$(cat << EOF
+code       :: cd ~/dev/condor/bitbucket/AWS
+tickets    :: cd ~/dev/condor/Tickets/head
+## -----------------------------------------
+cd_gambit  :: cd ~/dev/condor/bitbucket/AWS/aws-infra-Gambit/head/condor-gambit-infra
+## -----------------------------------------
+aws        :: cd ~/.aws
+bin        :: cd ~/.local/bin
+lcmdl      :: cd ~/lcmodules_local/head
+twins      :: cd ~/twins
+EOF
+)
+
+  local lnOpts=$(echo "${opts}" | grep -vE '^#' | grep -E "$(echo "$@" | tr -s ' ' | sed -E 's| |\.*|g')" | nl -i1 -n'rz' -v0 -w3)
+  local selOpt=$(echo "${lnOpts}" | sort -ru | sed -E 's|(.*::)(.*##)(.*)|\1\3|g' | grep -iE "${1}" | fzf | sed -E 's|(^[0-9]+)(.*)|\1|g')
+        selOpt=$(if [ "${selOpt}" == "" ]; then echo ""; else echo "${lnOpts}" | grep -E "^${selOpt}"; fi)
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+  selOpt=$( echo "${selOpt}" | sed  -E 's/(^.*)[ ]*::[ ]*(.*$)/\2/g' )
+
+  echo ">>>>>>> ${selOpt}"
+  eval "${selOpt}"
+}
+
+function winpath () {
+  base=$(echo "${1}" | sed -E 's|\\|/|g')
+  drive=$(echo "${base}" | cut -d ':' -f 1 | tr '[:upper:]' '[:lower:]')
+  drive=$(echo "/mnt/${drive}")
+  path=$(echo "${base}" | cut -d ':' -f 2)
+  echo "${drive}${path}"
+}
+
+## <<< general
+
+
+
+
+
+
+
+## -----------------------------------------------------------------------------
+. ~/.local/bin/envaws
+. ~/.local/bin/git
+. ~/.local/bin/clouddk

+ 69 - 0
clouddk

@@ -0,0 +1,69 @@
+alias   cdk='cdkdtct;eval $(echo "${NVM_INC}/bin/cdk" | rev | cut -d '/' -f 1-2,5-99 | rev)'
+alias  cdki='npm install'
+alias  cdkv='cdk synth'
+alias  cdkp='cdk deploy --no-execute'
+alias  cdka='cdk deploy'
+alias  cdkw='cdk watch'
+
+
+
+
+function ch(){
+local opts=$(cat << EOF
+cdk             ::   . ______________
+cdk_init        ::   cdk init app --language typescript
+cdk_boot_def    ::   cdk bootstrap
+cdk_boot_nodef  :x:  $(printf  "cdk bootstrap --qualifier '%s'" "${1}" ) 
+cdk_boot_imprt  ::   cdk bootstrap aws://%s/%s 
+cdk_synth       ::   cdk synth
+npm             ::   . ______________
+npm_inst        ::   npm install
+npm_inst        ::   npx tsc
+crs             ::   . ______________
+crs_link        ::   $(printf "rm -f ~/dev/cursor/* ; ln -s '%s' '%s/dev/cursor/cdk_stuff_%s'"  "${PWD}" "${HOME}" "$(pwd | sed -E 's|(.*)/head/(.*)|\1|g' | rev | cut -d '/' -f 1 | rev)")
+EOF
+)
+
+  local selOpt=$(echo "${opts}" | grep -vE '^##' | nl -i1 -n'rz' -v0 -w3 | sort -ru | fzf)
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+
+  selOpt=$(echo "${selOpt}" | tr '\t' ' ' | tr -s ' ')
+
+    prfx=$( echo "${selOpt}" | cut -d ' ' -f 2     )
+    mode=$( echo "${selOpt}" | cut -d ' ' -f 3     )
+  selOpt=$( echo "${selOpt}" | cut -d ' ' -f 4-999 )
+
+  ## echo "${prfx}"
+  ## echo "${mode}"
+  ## echo "${selOpt}"
+
+  case "${prfx}" in
+    cdk_boot_imprt)
+      selOpt=$(printf "${selOpt}" "$(aws sts get-caller-identity --query "Account" --output text)" "$(aws configure get region)")
+      ;;
+    *)
+      ;;
+  esac
+  
+
+  echo ">>>>>>> ${selOpt}"
+  history -s "${selOpt}"
+  if [[ "$mode" == ":x:" ]]; then history -s "ch '$@'"; else history -s "ch"; fi
+  eval "${selOpt}"
+}
+
+
+
+function cdkdtct(){
+    if [ 1 == 0 ]                                                             ; then echo 'huhu'                                                              ;
+
+  ## ## -- DUMMY - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "cdk-vpc-demo"     ] ; then nvm use 24.15 ; export AWS_PROFILE=122217416383_AAPowerAdministrator ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 3   | rev) == "aws-infra-Gambit" ] ; then nvm use 24.15 ; export AWS_PROFILE=304321522464_PowerUserAccess      ;
+
+  fi
+}

+ 138 - 0
envaws

@@ -0,0 +1,138 @@
+#!/bin/bash
+function ah(){
+local opts=$(cat << EOF
+aws.sshkeygen.pem  :: $(printf "ssh-keygen -m PEM -t rsa -b 2048 -f '%s.pem' -q -N '' && chmod 400 '%s.pem'" "${1}" "${1}")
+aws.sshkeygen.pub  :: $(printf "ssh-keygen -f '%s' -y" "${1}")
+aws.instcon        :: $(printf "aws ec2-instance-connect --region eu-central-1 ssh --instance-id %s" "$(xsel -bo | dos2unix |  head -n 1 | tr -d '\n\r ')" )
+aws.selProf        :: awsProfileSelect
+aws.store          :: awsStoreSecrets
+EOF
+)
+
+  local selOpt=$(echo "${opts}" | grep -vE "^##" | nl -i1 -n'rz' -v0 -w3 | sort -ru | fzf)
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+
+  selOpt=$( echo "${selOpt}" | sed  -E 's/(^.*)[ ]*::[ ]*(.*$)/\2/g' )
+
+  echo ">>>>>>> ${selOpt}"
+  history -s "${selOpt}"
+  history -s "ah"
+  eval "${selOpt}"
+}
+
+function awscliMFA(){
+  expiration=''
+  unset $(env | grep -E '^AWS' | grep -v 'PROFILE' | cut -d '=' -f 1)
+
+  local aws_mfa_serial=""
+  local aws_profile=""
+  local aws_role_arn=""
+  local aws_source_profile=""
+
+  aws_profile=$(cat ~/.aws/config | grep -E '^\[profile' | sed -E 's|(^\[profile )(.*)(\].*)|\2|g' | fzf)
+  aws_source_profile=$(aws configure --profile "${aws_profile}" get source_profile | sed -E 's|(.*)(_MFA)|\1|g')
+  aws_role_arn=$(aws configure --profile "${aws_profile}" get role_arn)
+
+  if [ "${aws_source_profile}" == "" ]; then
+    aws_source_profile="${aws_profile}"
+  fi
+
+  aws_mfa_serial=$(aws configure  --profile "${aws_source_profile}" get mfa_serial)
+
+  if [ "${aws_role_arn}" == "" ]; then
+    local content=$(
+        echo "[${aws_profile}_MFA]"
+        while read  -r line; do
+            cmd=''
+            key=$(echo $line | cut -d ':' -f 1                          )
+          value=$(echo $line | cut -d ':' -f 2-99 | sed -E 's|^[ ]*||g' )
+
+            if [ "${key}" == 'AccessKeyId'     ];then echo "aws_access_key_id = ${value}"
+          elif [ "${key}" == 'SecretAccessKey' ];then echo "aws_secret_access_key = ${value}"
+          elif [ "${key}" == 'SessionToken'    ];then echo "aws_session_token = ${value}"
+          fi
+        done < <(aws sts get-session-token --profile "${aws_source_profile}" --serial-number "${aws_mfa_serial}" --output yaml --token-code "${1}")
+    )
+
+    content=$(printf "##>>> %s\n%s\n##<<< %s" "${aws_profile}_MFA" "${content}" "${aws_profile}_MFA")
+
+    echo "${content}"
+    echo "${content}" | xsel -bi
+
+    sed -i '/^##>>> '"${aws_profile}_MFA"'/,/^##<<< '"${aws_profile}_MFA"'/{/^##>>> '"${aws_profile}_MFA"'/!{/^##<<< '"${aws_profile}_MFA"'/!d}}' ~/.aws/credentials
+    while read  -r line; do
+      sed -i -E 's|^##<<< '"${aws_profile}_MFA"'$|'"${line}"'\n##<<< '"${aws_profile}_MFA"'|g' ~/.aws/credentials
+    done < <(echo "${content}" | sed '1d')
+    sed -i -e '/##<<< '"${aws_profile}_MFA"'/{n;d}' ~/.aws/credentials
+  fi
+
+  if [ "${aws_role_arn}" != "" ]; then
+    local content=$(
+        echo "[${aws_profile}]"
+        while read  -r line; do
+            cmd=''
+            key=$(echo $line | cut -d ':' -f 1                          )
+          value=$(echo $line | cut -d ':' -f 2-99 | sed -E 's|^[ ]*||g' )
+
+            if [ "${key}" == 'AccessKeyId'     ];then echo "aws_access_key_id = ${value}"
+          elif [ "${key}" == 'SecretAccessKey' ];then echo "aws_secret_access_key = ${value}"
+          elif [ "${key}" == 'SessionToken'    ];then echo "aws_session_token = ${value}"
+          fi
+        done < <(aws sts assume-role  --profile "${aws_source_profile}" --role-arn "${aws_role_arn}" --role-session-name admin --serial-number "${aws_mfa_serial}" --output yaml --token-code "${1}")
+    )
+
+    content=$(printf "##>>> %s\n%s\n##<<< %s" "${aws_profile}" "${content}" "${aws_profile}")
+
+    echo "${content}"
+    echo "${content}" | xsel -bi
+
+    sed -i '/^##>>> '"${aws_profile}"'/,/^##<<< '"${aws_profile}"'/{/^##>>> '"${aws_profile}"'/!{/^##<<< '"${aws_profile}"'/!d}}' ~/.aws/credentials
+    while read  -r line; do
+      sed -i -E 's|^##<<< '"${aws_profile}"'$|'"${line}"'\n##<<< '"${aws_profile}"'|g' ~/.aws/credentials
+    done < <(echo "${content}" | sed '1d')
+    sed -i -e '/##<<< '"${aws_profile}"'/{n;d}' ~/.aws/credentials
+  fi
+}
+
+function awsProfileSelect(){
+  selection=$(
+    while read  -r line; do
+        clearName=$(echo "${line}" | cut -d ' ' -f 1)
+      accountName=$(echo "${line}" | cut -d ' ' -f 2)
+
+      printf "%-30s %s\n" "${clearName}" "${accountName}"
+    done < <(cat ~/.aws/config | grep -E '^\[profile.*##' | sed -E 's|(^[profile[ ]*)(.*)(\].*)(.*##)(.*)|\5 \2|g')
+  )
+
+  selection=$(echo "${selection}" | fzf)
+  selection=$(echo "${selection}" | tr -s ' ' | cut -d ' ' -f 2)
+  echo "${selection}"
+
+  export AWS_PROFILE="${selection}"
+}
+
+function awsStoreSecrets(){
+       hit="0"
+   content="$(xsel -bo | dos2unix )"
+
+  headline="$(printf "${content}" |  head -n 1)"
+
+  collector=''
+
+  while read line; do
+    ##echo ">>>${headline}<<<  <<<$(printf "${line}")>>>  ===${hit}==="
+
+      if [ 1 == 0                                            ]  ; then echo 'huhu' ;
+    elif [ "${headline}" == "${line}" ] && [ "${hit}" == "0" ]  ; then hit='1' ; collector=$(printf "${collector}%s" "$(printf "${content}")\n") ;
+    elif [ "${line}" == ""            ] && [ "${hit}" == "1" ]  ; then hit='0'     ;
+    fi
+
+    if [ "${hit}" == "0" ]; then collector=$(printf "${collector}%s" "${line}\n"); fi
+  done < <(cat ~/.aws/credentials | dos2unix)
+
+  printf "${collector}" >~/.aws/credentials
+}

+ 144 - 0
git

@@ -0,0 +1,144 @@
+#!/bin/bash
+
+alias ga='  git add'
+alias gaa=' git add -A'
+alias gau=' git add -u'
+alias gba=' git branch -a'
+alias gbak='git commit -m "BAK ##$(date +"%Y-%m-%dT%T%z")"'
+alias gcc=' git checkout -- .'
+alias gd='  git diff'
+alias gdt=' git difftool --dir-diff'
+alias gex=' rm -Rfv .git ; git init ; git add -A'
+alias gfak='git pull ; git add -u ; git commit -m "BAK ##$(date +"%Y-%m-%dT%T%z")" ; git push'
+alias gg='  git log --graph --decorate --oneline --no-abbrev-commit'
+alias ghr=' ls -1A | grep -vE .git$ | xargs -rI{} rm -Rf '{}' && git checkout -- .'
+alias gl='  git log'
+alias gpp=' git pull ; git push'
+alias gs='  git status'
+
+function gall(){
+  if [ "${2}" == "" ]; then
+    find . -type d | sort -u | grep -E "\.git$" | sed "s|\/\.git||" | sed "s|^\.|$PWD|" | xargs -I{} bash -c "cd {} ; echo '"'>>>>>>>>>> {}'"' ; ${1}"
+  else
+    find . -type d | sort -u | grep -E "\.git$" | grep -Ei "${2}" | sed "s|\/\.git||" | sed "s|^\.|$PWD|" | xargs -I{} bash -c "cd {} ; echo '"'>>>>>>>>>> {}'"' ; ${1}"
+  fi
+}
+
+function gcuab(){
+  local  cb=$(git branch --show-current)
+  while read -r line; do
+    git checkout "${line}"
+    git pull
+
+    if [ "${1}" == '--crawler' ]; then
+      find -L . -type f -not -path '*/.git*'  |   \
+      xargs -rI{} grep -EH '^' '{}' >../$(pwd |   \
+      sed -E "s|.*/(.*)|\1_${line}_allCnt\.txt|g")
+    fi
+
+  done < <(git branch -a | grep -F 'remotes' | sed -E 's|(^[ ]*remotes/origin/)||g' | cut -d ' ' -f 1)
+
+  git checkout "${cb}"
+}
+
+function gbswitch(){
+  while read -r line; do
+    git checkout "${line}"
+    git pull
+  done < <(git branch -a | grep -F 'remotes' | sed -E 's|(^[ ]*remotes/origin/)||g' | cut -d ' ' -f 1 | fzf)
+}
+
+
+function gmm(){
+  local  cb=$(git branch --show-current)
+  local mst=$(git branch | grep -E 'main|master' | tr -s ' '  | cut -d ' ' -f 2)
+  git checkout "${mst}"
+  git pull
+  git checkout "${cb}"
+  git merge "${mst}"
+}
+
+function gh(){
+local opts=$(cat << EOF
+add                     :q:  . ______________
+add_adoc                :q:  find | grep -E \.adoc$ | xargs -rI{} git add '{}'
+branch                  :q:  . ______________
+branch_byRepo_local     :q:  echo "${1}" | xargs -rI{} bash -c "git checkout -b '{}' ; git push --set-upstream origin '{}'"
+branch_remaster         :q:  cd ../master ; git pull ; git fetch --prune ; cd ../head ; rm -Rf .git ; cp -R ../master/.git .
+branch_setupstream      :q:  git push --set-upstream origin $(git branch --show-current)
+log                     :q:  . ______________
+log_branch              :q:  git --no-pager log --name-status >../$(pwd | sed -E 's|.*/(.*)|\1_git\.log|g')
+log_hist                :q:  git clone $(if [ -f 'repo.url' ]; then cat repo.url | grep -Ev '^##.*' ; fi) work ; cd work ; git checkout "${1}" ; git --no-pager log | grep -E "^commit " | sed -E "s|commit ||g" | xargs -rI{} bash -c 'git checkout "{}" ; find -L . -type f -not -path "*/.terraform*" -not -path "*/.git*" | xargs -rI{} file "{}" | grep -E "ASCII|text" | cut -d ":" -f 1 | sort -u --version-sort | xargs -rI@ grep -EH "^" "@" >"../\$(git log "{}" -n 1 --pretty=format:%cd --date=format:"%Y%m%d_%H%M%S")__{}.txt"'
+log_hist_nmbr           :q:  git clone $(if [ -f 'repo.url' ]; then cat repo.url | grep -Ev '^##.*' ; fi) work ; cd work ; git checkout "${1}" ; git --no-pager log | grep -E "^commit " | sed -E "s|commit ||g" | xargs -rI{} bash -c 'git checkout "{}" ; find -L . -type f -not -path "*/.terraform*" -not -path "*/.git*" | xargs -rI{} file "{}" | grep -E "ASCII|text" | cut -d ":" -f 1 | sort -u --version-sort | xargs -rI@ grep -EHn "^" "@" >"../\$(git log "{}" -n 1 --pretty=format:%cd --date=format:"%Y%m%d_%H%M%S")__{}.txt"'
+meta                    :q:  . ______________
+meta_info               :q:  echo -e "GIT_REPO:\t$(git config --get remote.origin.url)" && echo -e "CURRENT BRANCH:\t$(git branch --show-current)" && echo -e "LOG_INFO:\t$(git log --pretty=format:'%H [%cN] %aI %s' -n 1)"
+meta_origin             :q:  git config --get remote.origin.url
+## purge                :q:  . ______________
+purge                   :q:  find -type f | grep -F 'repo.url' | sed -E 's|(.*/).*|\1|g' | xargs -rI{} bash -c 'cd '{}' ; ls -1 | grep -vE "repo\.url|setup\.sh|froozen" | xargs rm -Rf ; git clone \$(if [ -f 'repo.url' ]; then cat repo.url | grep -vE '^#'; fi) head ; cp -R head master ; cd head ; git --no-pager log --name-status >../\$(pwd | sed -E "s|.*/(.*)|\1_git\.log|g") ; find -L . -type f -not -path '*/.terraform*' -not -path '*/.git*' | xargs -rI{} file "{}" | grep ASCII | cut -d ":" -f 1 | sort -u --version-sort | xargs -rI{} grep -EH '^' '{}' >../\$(pwd | sed -E "s|.*/(.*)|\1_allCnt\.txt|g") '
+purge_rcln              :q:  rm -Rf "$( if [ -f 'repo.url' ]; then cat repo.url | grep -E '^##' | sed -E 's|##||g' | rev | cut -d '/' -f1 | rev; fi)" ; git clone "$( if [ -f 'repo.url' ]; then cat repo.url | grep -E '^##' | sed -E 's|##||g'; fi)" ; rm -Rf head/.git ; mv "$( if [ -f 'repo.url' ]; then cat repo.url | grep -E '^##' | sed -E 's|##||g' | rev | cut -d '/' -f1 | rev; fi)/.git" head ; mv  "$( if [ -f 'repo.url' ]; then cat repo.url | grep -E '^##' | sed -E 's|##||g' | rev | cut -d '/' -f1 | rev; fi)/terraform.tfvars.json" head ; cd head ; git config --get remote.origin.url
+freeze                  :q:  cp -R head froozen
+twins                   :q:  . ______________
+twins_addRepo           :q:  find -type f | grep -E 'setup\.sh|repo.url' | grep -Ev '/\bhist\b/' | xargs -rI{} git add -f '{}'
+twins_purge             :q:  rm -Rf * ; git checkout -- . ; find -type f | grep -F 'repo.url' | sed -E 's|(.*/).*|\1|g' | xargs -rI{} bash -c 'cd '{}' ; ls -1 | grep -vE "repo\.url|setup\.sh" | xargs rm -Rf ; git clone \$(if [ -f 'repo.url' ]; then cat repo.url; fi) head ; cp -R head master ; cd head ; git --no-pager log --name-status >../\$(pwd | sed -E "s|.*/(.*)|\1_git\.log|g") ; find -L . -type f -not -path '*/.terraform*' -not -path '*/.git*' | xargs -rI{} file "{}" | grep ASCII | cut -d ":" -f 1 | sort -u --version-sort | xargs -rI{} grep -EH '^' '{}' >../\$(pwd | sed -E "s|.*/(.*)|\1_allCnt\.txt|g") '
+twins_forceAllFiles     :q:  find -L . -type f -not -path '*/.terraform*' -not -path '*/.git*' | xargs -rI{} git add -f '{}'
+EOF
+)
+
+  local selOpt=$(echo "${opts}" | grep -vE '^##' | nl -i1 -n'rz' -v0 -w3 | sort -ru | fzf)
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+
+    mode=$( echo "${selOpt}" | sed  -E 's/(^.*)([ ]*)(:[a-z]?:)([ ]*)(.*$)/\3/g' )
+  selOpt=$( echo "${selOpt}" | sed  -E 's/(^.*)([ ]*)(:[a-z]?:)([ ]*)(.*$)/\5/g' )
+
+  case $mode in
+    ":q:")
+      echo ">>>>>>> ${selOpt}"
+      history -s "${selOpt}"
+      eval "${selOpt}"
+      ;;
+    *)
+      echo ">>>>>>> ${selOpt} '$@'"
+      history -s "${selOpt} '$@'"
+      history -s "gh '$@'"
+      eval "${selOpt} '$@'"
+      ;;
+  esac
+}
+
+function lrepo(){
+  local LCMODULES_DIR="${HOME}/lcmodules_local/head"
+
+  local selOpt=$(find "${LCMODULES_DIR}" -not -path '*/.git*' | grep -E '/HEAD$' | sed -E "s|(${LCMODULES_DIR}/)(.*)/HEAD|\2|g" | sed -E 's|(.*)|  ::  \1|g' | grep -Ei "$(echo "$@" | tr -s ' ' | sed -E 's| |\||g')" | nl -i1 -n'rz' -v0 -w3 | sort -ru | fzf)
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+
+  selOpt=$( echo "${selOpt}" | sed  -E 's/(^.*)[ ]*::[ ]*(.*$)/\2/g' )
+
+  read -p "options ('p'lain/'s'ub): " a;
+
+  case $a in
+    "s")
+      sub=$(echo "${selOpt}" | sed -E "s|.*/(.*)|\1|g")
+      mkdir -p "${sub}" ; cd "${sub}"
+      ;;
+    "p")
+      ;;
+    *)
+      echo "-- Nothing to do --"
+      return
+      ;;
+  esac
+
+  selOpt="git init ; git remote add origin file://${LCMODULES_DIR}/$selOpt ; git fetch ; git reset origin/master ; git checkout master ; git push --set-upstream origin master"
+
+  echo ">>>>>>> ${selOpt}"
+  history -s "${selOpt}"
+  eval "${selOpt}"
+}

+ 177 - 0
terraform

@@ -0,0 +1,177 @@
+#!/bin/bash
+export TF_PLUGIN_CACHE_DIR="${HOME}/.terraform.d/plugin_cache_dir"
+cp ~/.terraform.d/credentials.tfrc.json.carglass ~/.terraform.d/credentials.tfrc.json
+
+alias  terraform='tfdtct;~/.tfenv/bin/terraform'
+
+alias      tf='terraform'
+alias  tfdocs='/usr/local/bin/terraform-docs'
+alias     tff='read -p "terraform fmt --recursive (yes/*): " a; case $a in "yes") terraform fmt --recursive ;; *) echo "-- Nothing to do --";; esac'
+alias     tfi='export TF_PLUGIN_CACHE_DIR="${HOME}/.terraform.d/plugin_cache_dir"; terraform init'
+alias     tfp='find -type f -not -path '"'"'*/.terraform*'"'"' -not -path '"'"'*/.git*'"'"' | grep -E "\.tf$|\.y*ml$" | xargs -rI{} sed -i -e '"'"'/./,$!d'"'"' -e :a -e '"'"'/^\n*$/{$d;N;ba'"'"' -e '"'"'}'"'"' -e '"'"'$a\'"'"' '"'"'{}'"'"' ; terraform plan -no-color'
+alias     tfv='terraform validate'
+alias     tii='read -p "terraform init --recursive (yes/*): " a; case $a in "yes") find -type d | grep -E '/account.*head$' | xargs -rI{} find '{}' -type f | grep -E '\.tf$' | grep -Fv '.terraform' | sed -E "s|(.*/head)(/.*)|\1|g" | sort -u | xargs -rI{} bash -c "cd "'"{}"'" ; terraform init";; *) echo "-- Nothing to do --";; esac'
+alias    tfaa='read -p "terraform apply --auto-approve (yes/*): " a; case $a in "yes") terraform apply --auto-approve ;; *) echo "-- Nothing to do --";; esac'
+
+alias  tf_bucketuse="grep -EH '\b(bucket|key|region|profile)\b[ ]*=[ ]*\"|\"terraform_remote_state\"' *"
+alias tf_resetstate='git status | grep -E '"'"'modified.*\.terraform\.lock\.hcl'"'"' | cut -d '"'"':'"'"' -f 2 | tr -s '"'"' '"'"' | sed -E '"'"'s| ||g'"'"' | xargs -rI{} bash -c "git reset -- '"'"'{}'"'"' ; git checkout -- '"'"'{}'"'"'"'
+
+function th(){
+local opts=$(cat << EOF
+code       :q: . ______________
+code       :q: find -type d | grep -E 'head$' | xargs -rI{} find '{}' -type f | grep -E '\.tf$' | grep -Fv '.terraform' | xargs -rI{} grep -E '\b(source|version)\b' {} | tr -s ' ' | sed -z 's|\n version = | \:\: |g' | sed -E 's| source = |##|g' | grep -E '^##' | sed -E 's|^##||g' | sort -u
+code       :q: find -type d | grep -E 'head$' | xargs -rI{} find '{}' -type f | grep -E '\.tf$' | grep -Fv '.terraform' | xargs -rI{} grep -HE '\b(source|version)\b' {} | tr -s ' '
+dck        :q: . ______________
+dckpc      :q: docker run --rm -e "USERID=$(id -u):$(id -g)" -v $(pwd):/lint -w /lint precommit run -a
+dckpc      :q: docker run -it --rm -v $(pwd):/lint -w /lint --entrypoint /bin/bash precommit -c "find . -type f -regex '.*\.tf$' -not -path '*/.terraform*' -not -path '*/.git*' | sed -E 's|(.*)(\/.*)|\1|g' | sort -u | xargs -rI{} bash -c 'cd "{}" ; terraform-docs asciidoc . >tfdocs.adoc'"
+dpr        :q: . ______________
+dprfmt     :q: find . -type f -regex '.*\.tf\$' -not -path '*/.terraform*' -not -path '*/.git*' | sed -E 's|(.*)(\/.*)|\1|g' | sort -u | xargs -rI{} bash -c 'cd "{}" ; echo ">>>> \${PWD}" ; terraform fmt'
+dprval     :q: find . -type f -regex '.*\.tf\$' -not -path '*/.terraform*' -not -path '*/.git*' | sed -E 's|(.*)(\/.*)|\1|g' | sort -u | xargs -rI{} bash -c 'cd "{}" ; echo ">>>> \${PWD}" ; terraform fmt ; terraform validate'
+dprxx      :q: find . -type f -regex '.*\.tf\$' -not -path '*/.terraform*' -not -path '*/.git*' | sed -E 's|(.*)(\/.*)|\1|g' | sort -u | xargs -rI{} bash -c 'cd "{}" ; echo ">>>> \${PWD}" ; ${1}'
+oth        :q: . ______________
+othca      :q: find . | grep -E '\.terraform$|/terraform\.|.terraform.*' | xargs -rI{} rm -Rfv '{}'
+othchm     :q: find -type d | xargs -rI{} chmod 755 '{}' ; find -type f | xargs -rI{} chmod 644 '{}'
+othd2u     :q: find . -type f -regex '.*\.tf$' -not -path '*/.terraform*' -not -path '*/.git*' | sed -E 's|(.*)(\/.*)|\1|g' | sort -u | xargs -rI{} bash -c 'cd "{}" ; echo ">>>> ${PWD}" ; dos2unix *'
+othmstcnt  :q: find . -type f -regex '.*\.tf$' -path '*/head*' -not -path '*/.terraform*' -not -path '*/.git*' | sort -u | xargs -rI{} grep -EH "^" '{}' >masterAllCnt.txt
+othsstcnt  :q: find -type f | grep -F 'state.json' | sort -u | xargs -rI{} grep -EH '^' '{}' >superState.txt
+othtar     :q: tar -czvf t_bin.tgz \$(find -type d | grep -E .terraform\$)
+plygrd     :q: . ______________
+plygrdbak  :q: ls -1 | grep -E '\.tf$' | sed -E 's|\.tf$||g' | xargs -rI{} mv '{}.tf' '{}.bak'
+plygrdyml  :q: echo "${1}" | xargs -rI{} bash -c "sed -i -E 's|            |  |g' '{}' ; sed -i -E 's|\"||g' '{}' ; sed -i -E 's|(^[ ]*\+ )([a-zA-Z0-9\-_]*)([ ]*= <<-EOT)|\2:|g' '{}' ; sed -i -E '/^[ ]*EOT/d' '{}'"
+prec       :q: . ______________
+precrun    :q: pre-commit run -a
+prectfd    :q: find . -type f -regex '.*\.tf$' -not -path '*/.terraform*' -not -path '*/.git*' | sed -E 's|(.*)(\/.*)|\1|g' | sort -u | xargs -rI{} bash -c 'cd "{}" ; terraform-docs asciidoc . >tfdocs.adoc'
+tf         :q: . ______________
+tfaply01   :q: echo '' >plan.txt ; terraform plan -no-color -lock=false 2>&1 | tee plan.txt
+tfaply01nr :q: echo '' >plan.txt ; terraform plan -no-color -refresh=false -lock=false 2>&1 | tee plan.txt
+tfaply02   :q: cat plan.txt | sort -u | grep -aE '^[ ]{2}#|^Plan'
+tfaply02   :q: cat plan.txt | grep -aE '(^[ ]*(~|\+|-|#))|^Plan'
+tfaply03   :q: terraform apply tfplan
+tfaply05   :q: cp plan.txt plan.bak ; sed -i  '0,/Changes to Outputs:/d' plan.txt
+tfaply05   :q: cp plan.txt plan.bak ; sed -i  '0,/Terraform used/d' plan.txt
+tffmt      :q: git status | grep -E '\.tf$' | grep -E 'modified|new file' | tr -s ' ' | cut -d ':' -f 2 | xargs -rI{} bash -c 'if [ "{}" != "" ]; then terraform fmt "{}"; fi'
+tfimpwp    :q: while true; do terraform plan -no-color -refresh=false -lock=false; sleep 20; done
+tfimpwv    :q: watch -n 3 'terraform validate'
+tfplan     :q: cat plan.txt | sort -u | grep -E '^[ ]{2}#|^Plan' >plan_sect.txt
+tfplan     :q: terraform plan -no-color | grep -E ' (#|~|\+|\-) |^Plan'
+tfplan     :q: terraform plan -no-color | sort -u | grep -E '^[ ]{2}#|^Plan'
+tfplangen  :q: if [ -f '${1}' ]; then  rm -v '${1}' ; fi ; terraform plan -refresh=false -generate-config-out='${1}'
+tfsort     :q: . ______________
+tfsort01   ::  sed -Ei "s|(^[data|module|resource|variable|import|moved])|###001\1|g" "${1}"; sed -Ei "N;s|\n|###002|g"
+tfsort02   ::  sed -Ei "s|###001|\n|g"
+tfsort03   ::  sed -Ei "N;s|\n||g"
+tfsort04   ::  sed -Ei "s|###002|\n|g"
+tfstte     :q: terraform show -no-color -json | yq -P >state.yaml
+tfstte     :q: terraform state pull           | yq -P >state.yaml
+tftarc     :q: tar -czvf '${1}.tgz' '${1}' && rm -Rf '${1}'
+tftarx     :q: tar -xzvf '$(echo "${1}" | sed -E 's|\.tgz$||g').tgz'
+EOF
+)
+
+  local selOpt=$(echo "${opts}" | grep -vE '^##' | nl -i1 -n'rz' -v0 -w3 | sort -ru | fzf)
+
+  if [ "${selOpt}" == "" ]; then
+    echo ">>>>>>> nothing selected, cancel ..."
+    return
+  fi
+
+    mode=$( echo "${selOpt}" | sed  -E 's/(^.*)([ ]*)(:[a-z]?:)([ ]*)(.*$)/\3/g' )
+  selOpt=$( echo "${selOpt}" | sed  -E 's/(^.*)([ ]*)(:[a-z]?:)([ ]*)(.*$)/\5/g' )
+
+  case $mode in
+    ":q:")
+      echo ">>>>>>> ${selOpt}"
+      history -s "${selOpt}"
+      eval "${selOpt}"
+      ;;
+    *)
+      echo ">>>>>>> ${selOpt} '$@'"
+      history -s "${selOpt} '$@'"
+      history -s "th '$@'"
+      eval "${selOpt} '$@'"
+      ;;
+  esac
+}
+
+function tfdtct(){
+    if [ 1 == 0 ]                                                                                         ; then echo 'huhu'                                                            ;
+
+  ## ## -- AppsA Germany - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 3   | rev) == "aws_german_project"                      ] ; then tfenv use 1.9.0   ; export AWS_PROFILE=122217416383_AAPowerAdministrator ;
+
+  ## ## -- AppsA Nuke  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "fsxontap"                                 ] ; then tfenv use 1.14.4  ; export AWS_PROFILE=122217416383_AAPowerAdministrator ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "nuke_csv"                                 ] ; then tfenv use 1.7.5   ; export AWS_PROFILE=122217416383_AAPowerAdministrator ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "nuke"                                     ] ; then tfenv use 1.7.5   ; export AWS_PROFILE=122217416383_AAPowerAdministrator ;
+
+  ## ## -- Belron AT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bat-backup-prod"                  ] ; then tfenv use 1.8.5   ; export AWS_PROFILE=BAT_BACKUP_PROD_MFA               ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bat-mangement-prod"               ] ; then tfenv use 1.8.5   ; export AWS_PROFILE=036446437541_BDE_AWS_FULL-ADMIN   ;
+
+  ## ## -- Belron DE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-backup-prod"                  ] ; then tfenv use 1.7.5   ; export AWS_PROFILE=036446437541_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-buildtools-prod"              ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=821263843247_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-login-prod"                   ] ; then tfenv use 1.7.5   ; export AWS_PROFILE=834490809680_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-main-crp"                     ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=868393128331_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-main-dev"                     ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+  ##elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-main-prod"                    ] ; then tfenv use 1.7.5   ; export AWS_PROFILE=888075181356_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-main-prod"                    ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=888075181356_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-main-uat"                     ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=710117937344_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-management-prod"              ] ; then tfenv use 1.7.5   ; export AWS_PROFILE=807893708968_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-network-prod"                 ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=310770523134_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-oracle-crp"                   ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=668227157566_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-oracle-dev"                   ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=441345502585_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-oracle-prod"                  ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=817423156165_BDE_AWS_FULL-ADMIN   ;
+  ##elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-oracle-uat"                   ] ; then tfenv use 1.7.5   ; export AWS_PROFILE=215958754683_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-oracle-uat"                   ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=215958754683_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-qlikview-prod"                ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=341319228646_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-qlikview-uat"                 ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=657103446090_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-sandbox-dev"                  ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=563703158576_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-security-audit"               ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=637423577158_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-shared-prod"                  ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=305856399206_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-tools-prod"                   ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=171713597515_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bde-workspace-prod"               ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=339713055671_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "account-bju-main-prod"                    ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=999245401427_AdministratorAccess  ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "ebs-crp"                                  ] ; then tfenv use 1.3.5   ; export AWS_PROFILE=868393128331_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "ebs-dev"                                  ] ; then tfenv use 1.3.5   ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "ebs-prod"                                 ] ; then tfenv use 1.3.5   ; export AWS_PROFILE=888075181356_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "ebs-uat"                                  ] ; then tfenv use 1.3.5   ; export AWS_PROFILE=710117937344_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "k8s-dev"                                  ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "k8s-prod"                                 ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "k8s-uat"                                  ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "terraform-aws-account"                    ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "terraform-aws-cassandra"                  ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "terraform-aws-grc-ec2-oel-v610"           ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+  elif [ $(echo "${PWD}" | rev | cut -d '/' -f 2   | rev) == "terraform-aws-group-appsassociate-admins" ] ; then tfenv use 1.14.8  ; export AWS_PROFILE=365628033575_BDE_AWS_FULL-ADMIN   ;
+
+
+  fi
+}
+
+function tfi_deep() {
+  startDir="${PWD}"
+
+  while  IFS= read res; do
+    targetDir="${startDir}/${res}"
+
+    cmd=$(printf "cd \"%s\" ; terraform init -no-color -backend=false" "${targetDir}")
+    echo "${cmd}"
+    eval "${cmd}"
+  done < <(find -type d | grep -E '/head$' | sort -u)
+
+  cd "${startDir}"
+}
+
+function tfs_deep() {
+  startDir="${PWD}"
+
+  while  IFS= read res; do
+    targetDir="${startDir}/${res}"
+
+    cmd=$(printf "cd \"%s\" ; tf state pull >state.json" "${targetDir}")
+    echo "${cmd}"
+    eval "${cmd}"
+  done < <(find -type d | grep -E '/head$' | sort -u)
+
+  cd "${startDir}"
+}