support arch
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user