# shellcheck shell=bash
### Constants ###

export CYAN_COLOR NO_COLOR
CYAN_COLOR=$(echo -e '\e[36m')
NO_COLOR=$(echo -e '\e[0m')

### Functions ###

function trap_commands() {
    # Function to print each bash command before it is executed
    trap '! [[ "$BASH_COMMAND" =~ ^(echo|read|\[|while|for) ]] &&
          ctxt="${cluster:+[${cluster}]}" &&
          cmd=`eval echo "[${PWD##*/}]\$ $ctxt $BASH_COMMAND" 2>/dev/null` &&
          echo "${CYAN_COLOR}$cmd${NO_COLOR}" >&2; true' DEBUG
}

### Main ###

set -T
trap_commands
