diff --git a/ask b/ask index 9e21923..e1278da 100755 --- a/ask +++ b/ask @@ -1,10 +1,12 @@ #!/usr/bin/env bash : <<'DOC' -ask — AI terminal assistant (macOS) +ask — AI terminal assistant (macOS/Linux) -Setup API key (Keychain): +Setup API key (macOS Keychain): security add-generic-password -a "$USER" -s TK_AI_API_TOKEN -w "YOUR_API_KEY" +Setup API key (Arch/Linux — libsecret): + echo "YOUR_API_KEY" | secret-tool store --label "AI API Token" service TK_AI_API_TOKEN Usage: ask "question" @@ -17,6 +19,15 @@ SERVER="https://ai.acbpro.com/v1/chat/completions" MODEL="gpt-5.3-codex" KEY_NAME="TK_AI_API_TOKEN" +# ===== OS DETECTION ===== +if [ -f /etc/arch-release ]; then + OS="arch" +elif [ "$(uname -s)" = "Darwin" ]; then + OS="macos" +else + OS="linux" +fi + VERBOSE=0 INTERACTIVE=0 @@ -37,10 +48,17 @@ while [[ "$1" == -* ]]; do done # ===== LOAD TOKEN ===== -API_TOKEN=$(security find-generic-password -a "$USER" -s "$KEY_NAME" -w 2>/dev/null | tr -d '\n') +case "$OS" in + macos) + API_TOKEN=$(security find-generic-password -a "$USER" -s "$KEY_NAME" -w 2>/dev/null | tr -d '\n') + ;; + *) + API_TOKEN=$(secret-tool lookup service "$KEY_NAME" 2>/dev/null | tr -d '\n') + ;; +esac if [ -z "$API_TOKEN" ]; then - echo "❌ API token not found in Keychain ($KEY_NAME)" + echo "❌ API token not found ($KEY_NAME)" >&2 exit 1 fi diff --git a/glm-quota b/glm-quota index 2b1296a..c7703ff 100755 --- a/glm-quota +++ b/glm-quota @@ -33,7 +33,14 @@ RESET="\033[0m" # ===== ARGS ===== VERBOSE=0 -[[ "$1" == "-v" ]] && VERBOSE=1 +ONELINE=0 +while [[ $# -gt 0 ]]; do + case "$1" in + -v) VERBOSE=1 ;; + -1) ONELINE=1 ;; + esac + shift +done # ===== LOAD TOKEN ===== case "$OS" in @@ -118,6 +125,11 @@ fi ICON=$(awk -v p="$T_PERCENT" 'BEGIN { if (p < 50) print "🟢"; else if (p > 80) print "🔴"; else print "🟡" }') +if [ "$ONELINE" -eq 1 ]; then + echo "GLM: ${T_PERCENT}%${REMAIN}${ICON}" + exit 0 +fi + echo "GLM: ${T_PERCENT}%${REMAIN}${ICON}" echo "---" echo "✅ Account: ${LEVEL}"