Customize AWS Q CLI shell execution

If you want to pull in your local .zshrc settings for each execute_bash command, you can follow the following steps:

  1. copy the following content to a new file named “myzsh” and put it somewhere in your local bin folder. I put it under ~/bin/myzsh
#!/bin/zsh

# Set to "allowlist" or "blocklist"
MODE="blocklist"

ALLOWED_PATTERNS=(
    '^ls'
    '^cat'
    '^echo'
    '^pwd'
    '^cd'
    '^grep'
    '^find'
    '^git'
)

NOT_ALLOWED_PATTERNS=(
    '^rm'
    '^sudo'
    '^chmod'
    'eval'
)

###########

check_command() {
    local cmd="$1"
    cmd=$(echo "$cmd" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')

    if [[ "$MODE" == "allowlist" ]]; then
        for pattern in "${ALLOWED_PATTERNS[@]}"; do
            if [[ "$cmd" =~ $pattern ]]; then
                return 0
            fi
        done
        return 1
    else
        for pattern in "${NOT_ALLOWED_PATTERNS[@]}"; do
            if [[ "$cmd" =~ $pattern ]]; then
                return 1
            fi
        done
        return 0
    fi
}

if [[ "$1" == "-c" ]]; then
    source ~/.zshrc

    echo "$2" | sed 's/[;&|]\+/\n/g' | while IFS= read -r cmd; do
        if ! check_command "$cmd"; then
            echo "Command checked by security rules: $cmd"
            printf "Run anyway? (y/n):\n" 
            if read -r response </dev/tty 2>/dev/null; then
                case "$response" in
                    y|yes) ;;
                    *) echo "Notice: Command skipped" >&2; exit 1 ;;
                esac
            else
                echo "Notice: Command skipped" >&2; exit 1
            fi
        fi
    done

    eval "$2"
else
    exec zsh "$@"
fi

2.

chmod +x ~/bin/myzsh
export AMAZON_Q_CHAT_SHELL="$HOME/bin/myzsh"

And use q chat as you normally do. in my case, it was able to see all the aliases I defined in my .zshrc file while before doing this it couldn’t see them. Also now you have full control on what command are allowed or blocked.

Alternatives to self-harming

I realized today why many teens self-harm (body-cutting, etc). It’s self-medication. Their mental state felt so stuck. They are trapped in negative thoughts, rumination, and brooding. A good way to snap out of it is to have some strong physical external shocks to their body (hopefully non-harmful). A quick run in the outdoor works. A cold shower. Jumping into a cold pool or river or the ocean. However, many times they do not have the motivation to do that since it takes energy/effort to do it. On the other hand, self-harming is likely one of the most accessible ways to provide that needed shock to relieve from the trapped negative state. This is similar to why many people drink accohol. It’s self medication.

With this realization, if parents can provide their teens with other less-harmful shocking mechanism above, maybe there will be less self-harming.

I realized that even forceful and consicious breathing can help, and that can be done anywhere anytime.

It's all about oxygen

We all know exercise is good for us, but here is my epiphany today: the reason might not be the workout itself —- it’s the fresh oxygen flooding our system.

Think about it. The activities that make us feel most alive—hiking, swimming, skiing, even a simple walk—all happen outdoors. That’s not a coincidence.

The indoor crisis

The average person spends 90% of their time indoors, breathing air that with higher CO2 levels that literally make us think slower. Studies show just 90 minutes in nature reduces activity in our brain’s rumination center, the part that keeps us stuck in negative thought loops. Meanwhile, prolonged indoor time increases depression risk by 60%.

When we exercise outdoors, we’re not just burning calories. We’re:

  • Supercharging our mitochondria with oxygen
  • Bathing in negative ions from natural environments
  • Absorbing phytoncides from trees that boost immune function
  • Breaking the rumination cycle that indoor living enables

Research proves that “green exercise” outperforms indoor workouts for mood, energy, and cognitive function.

Start small

  • Morning oxygen boost: 5 minutes outside stretching
  • Lunch break reset: Walk around the block
  • Evening wind-down: 10 minutes of outdoor breathing before bed

Level up

  • Exercise outdoors at least 3x per week
  • Work near an open window when possible
  • Take calls while walking outside
  • Eat one meal outdoors daily