#!/bin/bash12# GitHub Token Helper3# Dynamically retrieves GitHub token from git credentials4# Safe to source - will not error if git credentials are unavailable56# Only set GH_TOKEN if not already set and git credential is available7if [ -z "$GH_TOKEN" ] && command -v git >/dev/null 2>&1; then8# Attempt to get token from git credentials, suppress errors9TOKEN=$(printf 'protocol=https\nhost=github.com\n' | git credential fill 2>/dev/null | awk -F= '/password/ {print $2}' 2>/dev/null)1011# Only export if we got a non-empty token12if [ -n "$TOKEN" ]; then13export GH_TOKEN="$TOKEN"14fi1516unset TOKEN17fi181920