support arch
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
: <<'DOC'
|
: <<'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"
|
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:
|
Usage:
|
||||||
ask "question"
|
ask "question"
|
||||||
@@ -17,6 +19,15 @@ SERVER="https://ai.acbpro.com/v1/chat/completions"
|
|||||||
MODEL="gpt-5.3-codex"
|
MODEL="gpt-5.3-codex"
|
||||||
KEY_NAME="TK_AI_API_TOKEN"
|
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
|
VERBOSE=0
|
||||||
INTERACTIVE=0
|
INTERACTIVE=0
|
||||||
|
|
||||||
@@ -37,10 +48,17 @@ while [[ "$1" == -* ]]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# ===== LOAD TOKEN =====
|
# ===== 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
|
if [ -z "$API_TOKEN" ]; then
|
||||||
echo "❌ API token not found in Keychain ($KEY_NAME)"
|
echo "❌ API token not found ($KEY_NAME)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,14 @@ RESET="\033[0m"
|
|||||||
|
|
||||||
# ===== ARGS =====
|
# ===== ARGS =====
|
||||||
VERBOSE=0
|
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 =====
|
# ===== LOAD TOKEN =====
|
||||||
case "$OS" in
|
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 "🟡" }')
|
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 "GLM: ${T_PERCENT}%${REMAIN}${ICON}"
|
||||||
echo "---"
|
echo "---"
|
||||||
echo "✅ Account: ${LEVEL}"
|
echo "✅ Account: ${LEVEL}"
|
||||||
|
|||||||
Reference in New Issue
Block a user