Keep user-managed Dim and Kimi launchers and write Claude settings through fresh private files
This commit is contained in:
1 parent
23072924c4
commit
da6045be3f
5 files changed
+33
-11
No files matched your search
@@ -12,17 +12,15 @@ keys=(ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_MODEL ANTHROPIC_DEFAULT_
|
||||
|
||||
keys_json=$(printf '%s\n' "${keys[@]}" | jq -R . | jq -s .)
|
||||
|
||||
# rewrite <file> <jq filter> [jq args...] keeps the file private.
|
||||
# rewrite <file> <jq filter> [jq args...] replaces the file with a fresh 0600 copy.
|
||||
rewrite() {
|
||||
local file=$1 filter=$2
|
||||
local file=$1 filter=$2 tmp
|
||||
shift 2
|
||||
mkdir -p "${file%/*}"
|
||||
[[ -f $file ]] || echo '{}' >"$file"
|
||||
(
|
||||
umask 077
|
||||
jq --argjson keys "$keys_json" "$@" "$filter" "$file" >"$file.tmp"
|
||||
)
|
||||
mv "$file.tmp" "$file"
|
||||
tmp=$(mktemp "$file.XXXXXX")
|
||||
jq --argjson keys "$keys_json" "$@" "$filter" "$file" >"$tmp" || { rm -f "$tmp"; exit 1; }
|
||||
mv "$tmp" "$file"
|
||||
}
|
||||
|
||||
if [[ ${1:-} == "--remove" ]]; then
|
||||
|
||||
Reference in new issue
Block a user