Skip to content

Instantly share code, notes, and snippets.

@adrianbrowning
Created January 21, 2026 18:51
Show Gist options
  • Select an option

  • Save adrianbrowning/b8bd51f44cba22d5c81e09b6c1b38bcf to your computer and use it in GitHub Desktop.

Select an option

Save adrianbrowning/b8bd51f44cba22d5c81e09b6c1b38bcf to your computer and use it in GitHub Desktop.
in_thinking=false
while read -r line; do
thinking=$(echo "$line" | jq -r '.message.content[]? | select(.type == "thinking") | .thinking // empty' 2>/dev/null)
text=$(echo "$line" | jq -rj '.message.content[]? | select(.type == "text") | .text // empty' 2>/dev/null)
if [ -n "$thinking" ]; then
if [ "$in_thinking" = false ]; then
printf '\r\n───────────────\r\n💭 '
in_thinking=true
fi
printf '%s' "${thinking//$'\n'/$'\r\n'}"
fi
if [ -n "$text" ]; then
if [ "$in_thinking" = true ]; then
printf '\r\n───────────────\r\n'
in_thinking=false
fi
printf '%s' "$text"
fi
done < <(docker sandbox run claude -p "Hello World, wait 5 seconds then reply" --output-format stream-json --verbose )
# Handle response ending in thinking
if [ "$in_thinking" = true ]; then
printf '\r\n───────────────\r\n'
fi
echo # final newline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment