#!/bin/bash # Print a prompt file from $OLLIE/p/ to stdout for agentSpawn hook injection. # Usage: prime (resolves $OLLIE/p/ or $OLLIE/p/.md) # Performs environment variable substitution on the file contents. set -euo pipefail OLLIE="${OLLIE:-$HOME/mnt/ollie}" if [ $# -ne 1 ]; then echo "usage: prime " >&2 exit 1 fi NAME="$1" for path in "$OLLIE/p/$NAME" "$OLLIE/p/$NAME.md"; do if [ -f "$path" ]; then export PRIME_DATE="$(date +%Y-%m-%d)" export PRIME_PLATFORM="$(uname -s | tr '[:upper:]' '[:lower:]')" export PRIME_IS_GIT_REPO="$([ -e .git ] && echo true || echo false)" envsubst '${OLLIE} ${OLLIE_SESSION_ID} ${PWD} ${PRIME_DATE} ${PRIME_PLATFORM} ${PRIME_IS_GIT_REPO}' < "$path" exit 0 fi done echo "prime: prompt not found: $NAME" >&2 exit 1