Merge feature/openrouter-toggle into develop

This commit is contained in:
bchanot committed 2026-10-28 15:43:17 +01:00
commit 9b4d241725
9 files changed
+176 -76

No files matched your search

+7
View File
@@ -181,3 +181,10 @@ menu at plain-SSH login had to be quit once, then reopened inside tmux. Approved
shared session `main` (`new-session -A`), VS Code Remote-SSH excluded, all three rc files.
- [x] bash/bashrc-linux, bash/bashrc-osx, zsh/zshrc-osx: interactive + SSH + not in tmux + not vscode → `exec tmux new-session -A -s main`, just before the router line
- [x] shellcheck + bash -n + guard harness (env combos, tmux stubbed); zsh absent here, zsh block untested
## Feature — `openrouter` rc function replaces claude-provider (2026-10-28)
Branch: feature/openrouter-toggle (off develop). Shell function (bash + zsh): `openrouter` on, `-d`/`-u` off, key from `$OPENROUTER_API_KEY`.
- [x] bashrc-linux, bashrc-osx, zshrc-osx: `openrouter()`; snapshot of the 4 vars' prior values in `$_OPENROUTER_SAVED`, replayed on off
- [x] log out / log in reminders on on / off
- [x] remove bin/claude-provider + install.sh, README, CLAUDE.md refs; CHANGELOG Added/Removed
- [x] bash -n + harness (quoted value restore, unset restore, not-active, double on); zsh block untested (zsh absent)
+4
View File
@@ -6,6 +6,7 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: se
## [Unreleased]
### Added
- `bashrc-linux`, `bashrc-osx`, `zshrc-osx`: `openrouter` function switches Claude Code to OpenRouter in the current shell (`openrouter` on, `openrouter -d`/`-u` off). Key from `$OPENROUTER_API_KEY`; values the four variables held before are saved and restored on off; a reminder to log out / log in of Claude Code is printed.
- `install.sh` installs the Rust toolchain on both OSes with the official `rustup` script (`stable`, default profile + `rust-analyzer` `rust-src`, `rustup update` on a re-run, `--no-modify-path`); the deployed bashrc/zshrc source `~/.cargo/env`. `libssl-dev` (apt) / `openssl@3` (brew) added for `openssl-sys` crates.
- `install.sh` asks the gitflow push mode (`gitflow.autopush`, exactly `true` or `false`, Enter = `true`) and writes it to `~/.gitconfig`; an existing value is reused, `DOTFILES_GITFLOW_AUTOPUSH` presets it, any other preset aborts the install.
- `gitconfig`: fixed `core.hooksPath = ~/.claude/githooks`.
@@ -15,6 +16,9 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: se
- `tmux.conf`: Alt+Left/Right switch windows without the prefix (macOS: map Cmd+arrow in iTerm2 to the `[1;3D` / `[1;3C` escape sequences).
- `tmux.conf`: Ctrl+Alt+arrow moves between panes without the prefix, in copy-mode too (macOS: map Ctrl+Cmd+arrow in iTerm2 to `[1;7A` `[1;7B` `[1;7D` `[1;7C`).
### Removed
- `bin/claude-provider` (wrote a file nothing sourced), replaced by the `openrouter` rc function. A copy already deployed in `~/.local/bin` is not deleted by the installer.
### Changed
- `install.sh`: the GNOME desktop (`ubuntu-desktop-minimal`) and the RDP remote login are now offered (`[Y/n]` each, RDP only after the desktop) instead of always installed; on WSL both default to no, since Windows owns the display and the desktop's NetworkManager/systemd-resolved rewrite `/etc/resolv.conf` and break DNS mid-install.
- `.githooks/post-commit` and `post-merge` fail closed on `gitflow.autopush`: an unreadable or non-boolean value means no push, with a named warning (was: silently treated as `true`).
+3 -3
View File
@@ -26,7 +26,7 @@ gitconfig user-scope ~/.gitconfig template, @USER@/@EMAIL
(gitflow push mode, exact true/false) filled at install; core.hooksPath fixed
tmux.conf tmux config (vi keys, tpm plugins) → ~/.config/tmux/tmux.conf, both OSes (tmux ≥ 3.1)
zsh/{zshrc-osx,bchanot.zsh-theme} macOS zsh option: oh-my-zsh zshrc + theme porting the bash prompt
bin/{dt,dtach-router,claude-provider} CLI scripts deployed to ~/.local/bin
bin/{dt,dtach-router} CLI scripts deployed to ~/.local/bin
bin/tmux-copy-exit-keys run by tmux.conf at load: after a mouse selection any bare key leaves copy-mode
bin/repo-sync multi-forge repo tree (gitlab/github/gitea/bitbucket cloud) → ~/repos, daily cache;
tokens in ~/.config/repos/forges.conf (0600, never tracked); `repo` fn in the rc files
@@ -56,8 +56,8 @@ rc files source `~/.cargo/env`. Never add `rustc`/`cargo` to the apt or brew lis
`pymupdf`/`markdown_py` are NOT tracked — they are pipx entry-point shims,
recreated by `pipx install PyMuPDF Markdown` in install.sh.
`claude-provider` reads `$OPENROUTER_API_KEY` from the env — never hardcode it (the
original had a live key; it was scrubbed — see decisions/blockers).
The `openrouter` rc function reads `$OPENROUTER_API_KEY` from the env — never hardcode it (the
former `claude-provider` had a live key; it was scrubbed — see decisions/blockers).
## Commands
+1 -7
View File
@@ -35,7 +35,6 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/main/remote-install.
| `zsh/bchanot.zsh-theme` | oh-my-zsh theme reproducing the bash prompt: `✔ (12ms) user [ ~/dir ] [branch -*+] >`. |
| `bin/dt` | dtach session manager for claude-in-dtach sessions. |
| `bin/dtach-router` | Dashboard to resume dtach sessions, shown at the start of every interactive shell (wired into `~/.bashrc` by the installer). |
| `bin/claude-provider`| Switch Claude Code between Anthropic and OpenRouter. |
| `bin/tmux-copy-exit-keys` | Run by `tmux.conf` at load: after a mouse selection, any bare key leaves copy-mode (ctrl/alt keys and keyboard copy-mode keep their vi role). |
| `bin/repo-sync` | One local tree (`~/repos`) for every repository reachable on your forges (GitLab, GitHub, Gitea/Forgejo, Bitbucket Cloud), daily cache, `repo <project>` shell function to jump into one. |
| `etc/profile.d/disk-usage-warning.sh` | Login-time warning (bold red) when `/` or `/home` cross 85% usage. Deployed to `/etc/profile.d/` on Linux. |
@@ -70,7 +69,7 @@ What it does:
5. Copies the tracked vim files into `~/.vim` and symlinks `~/.vimrc`.
6. Picks the bashrc by OS: macOS → `bashrc-osx` (falls back to `bashrc-linux` if missing), everything else → `bashrc-linux`. Renders it into `~/.bashrc` with the identity asked at the very start: a name and an email for git commits and vim headers. An `export USER=` / `export EMAIL=` already present in `~/.bashrc` or `~/.zshrc` is reused without asking, so a re-run never prompts twice; `IDENTITY_USER` / `IDENTITY_EMAIL` preset them; with no terminal attached it falls back to the login name and an empty email. The values live only in the deployed files, never in the repo. Then renders `gitconfig` into `~/.gitconfig` with the same name and email (skipped, push mode included, when the name or email is empty, e.g. a first install with no terminal and no `IDENTITY_EMAIL`). The installer asks once whether the gitflow hooks push every commit and merge (`true` or `false` exactly, Enter = `true`); a `true`/`false` already in `~/.gitconfig` is reused without asking and survives the redeploy; `DOTFILES_GITFLOW_AUTOPUSH=true|false` presets it for a non-interactive install, an existing `~/.gitconfig` value still winning (no terminal and no preset gives `true`; any other preset aborts the install); the render refuses to write a file where `@AUTOPUSH@` leaked, since a non-boolean value blocks every push. To switch later: `git config --global gitflow.autopush true|false`. A different existing `~/.gitconfig` is saved as `~/.gitconfig.backup-<date>`; an identical one is left alone. It is the global level only: a repo's own `.git/config` still overrides it. `core.excludesfile` points at `~/.gitignore`, ignored by git when the file does not exist. `core.hooksPath` is fixed to `~/.claude/githooks`, the gitflow hooks created by `make link` in the claude-config repo; the installer neither creates nor checks that directory. Being global, it makes git ignore each repo's `.git/hooks/` unless that repo sets its own `core.hooksPath`. Then deploys `tmux.conf` to `~/.config/tmux/tmux.conf` (both OSes, tmux ≥ 3.1: Ubuntu 22.04+, brew), clones [tpm](https://github.com/tmux-plugins/tpm) and fetches the listed plugins headlessly; details under [macOS](#macos) step 6, the step is the same. On Linux, `y` copies into tmux's buffer and the terminal clipboard through OSC 52; macOS uses `pbcopy`/`pbpaste`.
7. Installs Python CLIs via `pipx` (`PyMuPDF` → `pymupdf`, `Markdown` → `markdown_py`) — skipped if `pipx` is absent. Then installs the **Rust toolchain** on both OSes with the official `rustup` script, as you, never `sudo`: `stable` toolchain, default profile (`rustc cargo rust-std rust-docs rustfmt clippy`) plus `rust-analyzer` and `rust-src` for IDE support. On a re-run an existing `rustup` is updated (`rustup update`) instead of reinstalled. The script runs with `--no-modify-path`: the deployed bashrc/zshrc source `~/.cargo/env` when it exists, which puts `~/.cargo/bin` on `PATH` once. `CARGO_HOME` and `RUSTUP_HOME` keep their defaults (`~/.cargo`, `~/.rustup`). `libssl-dev` (apt) / `openssl@3` (brew) are installed so crates on `openssl-sys` build.
8. Copies the `bin/` scripts (`dt`, `dtach-router`, `claude-provider`, `repo-sync`, `tmux-copy-exit-keys`) into `~/.local/bin`. The dtach session-resume menu ships in the deployed bashrc (both OSes), so every interactive shell offers it — including VS Code Remote-SSH terminals, which are non-login and never read `~/.profile`. The installer also strips any older dtach block left in `~/.profile` so a plain SSH login doesn't prompt twice.
8. Copies the `bin/` scripts (`dt`, `dtach-router`, `repo-sync`, `tmux-copy-exit-keys`) into `~/.local/bin`. The dtach session-resume menu ships in the deployed bashrc (both OSes), so every interactive shell offers it — including VS Code Remote-SSH terminals, which are non-login and never read `~/.profile`. The installer also strips any older dtach block left in `~/.profile` so a plain SSH login doesn't prompt twice.
9. On Linux, installs `etc/profile.d/disk-usage-warning.sh` to `/etc/profile.d/` (needs `sudo`) so each login warns when `/` or `/home` cross 85% usage.
10. On Linux, installs **code-server** (VS Code in the browser) via its vendor script — skipped if already present — and enables the `code-server@<login>` systemd service (login from `id -un`: the bashrc overrides `$USER`).
11. On Linux, **offers** (`[Y/n]`, Enter = yes) to install **`ubuntu-desktop-minimal`** (GDM + GNOME Shell, ~1.5 GB): the RDP remote login below hands out a GNOME session, which a bare server install does not have. If accepted, then **offers** (`[Y/n]`) **RDP remote login** via `gnome-remote-desktop` (Wayland-native); no desktop means no RDP question. On **WSL** (`WSL_DISTRO_NAME` set or `microsoft` in `/proc/version`) both default to **no** (`[y/N]`): Windows owns the display, and the desktop drags in NetworkManager + systemd-resolved, which rewrite `/etc/resolv.conf` and break DNS for the rest of the install. With no terminal attached the default applies. The RDP setup installs the daemon + `openssl`, generates a self-signed TLS cert once, and prompts interactively for shared "gate" credentials (skipped when no terminal is attached, or already set). Disables `xrdp` if present; opens UFW port `3389` only when UFW is already active. Finally, when `lspci` sees an NVIDIA GPU, runs `ubuntu-drivers install` to put on the driver the distro recommends for the card (no version pinned; loads at the next reboot). Skipped on machines without an NVIDIA GPU.
@@ -135,11 +134,6 @@ Deployed to `~/.local/bin` (the deployed bashrc adds this dir to `PATH`):
- **`dt`** — manage claude-in-dtach sessions (`dt ls|at|kill`). Needs `dtach` + `fzf`.
- **`dtach-router`** — session dashboard shown at shell startup. It ships in the deployed bashrc and is **sourced** (not executed) in every interactive shell, so it also fires in VS Code Remote-SSH terminals (non-login shells that skip `~/.profile`). Silent no-op when no session exists. Create a session with `cc [name]`, re-open the menu anytime with `d` (both aliases from the bashrc). Needs `dt`, `dtach`, `fzf`.
- **`claude-provider`** — switch Claude Code between Anthropic and OpenRouter.
OpenRouter mode reads the key from **`$OPENROUTER_API_KEY`** (never hardcoded). Export it from a private, untracked file, e.g. `~/.bashrc.local`:
```sh
export OPENROUTER_API_KEY="<your-openrouter-key>"
```
- **`repo-sync`** — one local tree for every git repository you can reach on your forges, same layout as the Alphalink `repo` zsh function: `~/repos/<namespace with / as @>/<project>` (`REPOS_DIR` overrides). Needs `jq`, `curl`, `git`.
- `repo-sync add` registers a forge (type `gitlab|github|gitea|bitbucket`, host, token asked on the terminal) in **`~/.config/repos/forges.conf`** (mode 0600, parsed line by line, never tracked). Run it once per access you have. GitHub Enterprise and self-hosted GitLab/Gitea work by host; Bitbucket is Cloud only (Atlassian email + API token).
- `repo-sync refresh` rebuilds the project list in `~/.cache/repos/list` when it is older than a day (`--force` to redo it now). The deployed rc files run it in the background at shell start, so the list is fresh at most once per day without a cron.
+53
View File
@@ -142,6 +142,59 @@ alias cc='dtach_claude'
# Rappeler a la demande le menu de reprise.
alias d='source ~/.local/bin/dtach-router'
# openrouter : bascule Claude Code sur OpenRouter dans le shell courant (fonction, pas
# script : un script ne peut pas modifier l'environnement de son parent). `openrouter`
# active, `openrouter -d` (ou -u) desactive. La cle vient de $OPENROUTER_API_KEY, a
# exporter depuis un fichier prive non versionne (~/.bashrc.local, ~/.zshrc.local).
# Les valeurs qu'avaient deja ces variables sont gardees dans $_OPENROUTER_SAVED
# (commandes export/unset) et rejouees a la desactivation.
openrouter() {
local v saved=""
case "${1:-}" in
-d | -u)
if [ -n "${_OPENROUTER_SAVED+x}" ]; then
saved="$_OPENROUTER_SAVED"
elif [ "${ANTHROPIC_BASE_URL:-}" != "https://openrouter.ai/api" ]; then
echo "openrouter: not active"
return 0
fi
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY
eval "$saved"
unset _OPENROUTER_SAVED
echo "openrouter: off"
echo "Pensez a vous log in de Claude Code"
;;
"")
[ -n "${OPENROUTER_API_KEY:-}" ] || {
echo "openrouter: OPENROUTER_API_KEY is not set" >&2
return 1
}
if [ -z "${_OPENROUTER_SAVED+x}" ]; then
for v in ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY; do
if printenv "$v" >/dev/null; then
saved="$saved export $v=$(printf %q "$(printenv "$v")");"
else
saved="$saved unset $v;"
fi
done
_OPENROUTER_SAVED="$saved"
fi
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY="" # doit etre explicitement vide
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
echo "openrouter: on"
echo "Pensez a vous logout de Claude Code"
;;
*)
echo "usage: openrouter [-d|-u]" >&2
return 1
;;
esac
}
# repo-sync : un arbre local (~/repos) pour tous les depots des forges declarees
# dans ~/.config/repos/forges.conf. `repo <projet> [namespace]` clone si besoin
# puis s'y place ; la liste se rafraichit en arriere-plan, au plus 1 fois par jour.
+53
View File
@@ -152,6 +152,59 @@ alias cc='dtach_claude'
# Rappeler a la demande le menu de reprise.
alias d='source ~/.local/bin/dtach-router'
# openrouter : bascule Claude Code sur OpenRouter dans le shell courant (fonction, pas
# script : un script ne peut pas modifier l'environnement de son parent). `openrouter`
# active, `openrouter -d` (ou -u) desactive. La cle vient de $OPENROUTER_API_KEY, a
# exporter depuis un fichier prive non versionne (~/.bashrc.local, ~/.zshrc.local).
# Les valeurs qu'avaient deja ces variables sont gardees dans $_OPENROUTER_SAVED
# (commandes export/unset) et rejouees a la desactivation.
openrouter() {
local v saved=""
case "${1:-}" in
-d | -u)
if [ -n "${_OPENROUTER_SAVED+x}" ]; then
saved="$_OPENROUTER_SAVED"
elif [ "${ANTHROPIC_BASE_URL:-}" != "https://openrouter.ai/api" ]; then
echo "openrouter: not active"
return 0
fi
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY
eval "$saved"
unset _OPENROUTER_SAVED
echo "openrouter: off"
echo "Pensez a vous log in de Claude Code"
;;
"")
[ -n "${OPENROUTER_API_KEY:-}" ] || {
echo "openrouter: OPENROUTER_API_KEY is not set" >&2
return 1
}
if [ -z "${_OPENROUTER_SAVED+x}" ]; then
for v in ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY; do
if printenv "$v" >/dev/null; then
saved="$saved export $v=$(printf %q "$(printenv "$v")");"
else
saved="$saved unset $v;"
fi
done
_OPENROUTER_SAVED="$saved"
fi
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY="" # doit etre explicitement vide
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
echo "openrouter: on"
echo "Pensez a vous logout de Claude Code"
;;
*)
echo "usage: openrouter [-d|-u]" >&2
return 1
;;
esac
}
# repo-sync : un arbre local (~/repos) pour tous les depots des forges declarees
# dans ~/.config/repos/forges.conf. `repo <projet> [namespace]` clone si besoin
# puis s'y place ; la liste se rafraichit en arriere-plan, au plus 1 fois par jour.
-63
View File
@@ -1,63 +0,0 @@
#!/bin/bash
# Switch Claude Code between Anthropic (default) and OpenRouter.
# Usage: claude-provider [anthropic|openrouter|status]
# After switching, re-source your shell or run: cpsource
#
# OpenRouter mode reads the API key from $OPENROUTER_API_KEY at source time —
# the key is NOT stored in this script or in the repo. Export it from a private,
# untracked location (e.g. ~/.bashrc.local):
# export OPENROUTER_API_KEY="<your-openrouter-key>"
PROVIDER_FILE="$HOME/.claude-provider-env"
write_anthropic() {
cat > "$PROVIDER_FILE" << 'EOF'
# Claude provider: Anthropic (default)
unset ANTHROPIC_BASE_URL
unset ANTHROPIC_API_KEY
unset ANTHROPIC_DEFAULT_SONNET_MODEL
export CLAUDE_PROVIDER="anthropic"
EOF
echo "Switched to Anthropic (default)."
echo "Run: cpsource (or restart your shell)"
}
write_openrouter() {
cat > "$PROVIDER_FILE" << 'EOF'
# Claude provider: OpenRouter
# Key comes from $OPENROUTER_API_KEY in your environment (never hardcoded here).
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_API_KEY="${OPENROUTER_API_KEY:?Set OPENROUTER_API_KEY in your environment to use OpenRouter}"
export CLAUDE_PROVIDER="openrouter"
export ANTHROPIC_DEFAULT_SONNET_MODEL="google/gemma-4-31b-it:free"
EOF
echo "Switched to OpenRouter."
echo "Run: cpsource (or restart your shell)"
}
show_status() {
local provider="${CLAUDE_PROVIDER:-anthropic}"
echo "Current provider: $provider"
if [ -f "$PROVIDER_FILE" ]; then
echo "Config file: $PROVIDER_FILE"
fi
}
case "${1:-status}" in
openrouter|or)
write_openrouter
;;
anthropic|an)
write_anthropic
;;
status|st)
show_status
;;
*)
echo "Usage: claude-provider [anthropic|openrouter|status]"
echo " anthropic (an) — Use Anthropic directly (default)"
echo " openrouter (or) — Use OpenRouter proxy"
echo " status (st) — Show current provider"
exit 1
;;
esac
+2 -3
View File
@@ -883,14 +883,13 @@ fi
# Rust toolchain (rustup, user-level, both OSes).
install_rust
# Deploy personal CLI scripts to ~/.local/bin (dt, dtach-router, claude-provider, repo-sync,
# Deploy personal CLI scripts to ~/.local/bin (dt, dtach-router, repo-sync,
# tmux-copy-exit-keys).
echo "Deploying CLI scripts to ~/.local/bin"
mkdir -p "$HOME/.local/bin"
cp "$SCRIPT_DIR"/bin/* "$HOME/.local/bin/"
chmod +x "$HOME"/.local/bin/dt "$HOME"/.local/bin/dtach-router \
"$HOME"/.local/bin/claude-provider "$HOME"/.local/bin/repo-sync \
"$HOME"/.local/bin/tmux-copy-exit-keys
"$HOME"/.local/bin/repo-sync "$HOME"/.local/bin/tmux-copy-exit-keys
# Remove any stale dtach wiring from ~/.profile (the menu now ships in ~/.bashrc; see above).
+53
View File
@@ -69,6 +69,59 @@ alias cc='dtach_claude'
# Rappeler a la demande le menu de reprise.
alias d='source ~/.local/bin/dtach-router'
# openrouter : bascule Claude Code sur OpenRouter dans le shell courant (fonction, pas
# script : un script ne peut pas modifier l'environnement de son parent). `openrouter`
# active, `openrouter -d` (ou -u) desactive. La cle vient de $OPENROUTER_API_KEY, a
# exporter depuis un fichier prive non versionne (~/.bashrc.local, ~/.zshrc.local).
# Les valeurs qu'avaient deja ces variables sont gardees dans $_OPENROUTER_SAVED
# (commandes export/unset) et rejouees a la desactivation.
openrouter() {
local v saved=""
case "${1:-}" in
-d | -u)
if [ -n "${_OPENROUTER_SAVED+x}" ]; then
saved="$_OPENROUTER_SAVED"
elif [ "${ANTHROPIC_BASE_URL:-}" != "https://openrouter.ai/api" ]; then
echo "openrouter: not active"
return 0
fi
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY
eval "$saved"
unset _OPENROUTER_SAVED
echo "openrouter: off"
echo "Pensez a vous log in de Claude Code"
;;
"")
[ -n "${OPENROUTER_API_KEY:-}" ] || {
echo "openrouter: OPENROUTER_API_KEY is not set" >&2
return 1
}
if [ -z "${_OPENROUTER_SAVED+x}" ]; then
for v in ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY \
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY; do
if printenv "$v" >/dev/null; then
saved="$saved export $v=$(printf %q "$(printenv "$v")");"
else
saved="$saved unset $v;"
fi
done
_OPENROUTER_SAVED="$saved"
fi
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY="" # doit etre explicitement vide
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
echo "openrouter: on"
echo "Pensez a vous logout de Claude Code"
;;
*)
echo "usage: openrouter [-d|-u]" >&2
return 1
;;
esac
}
# repo-sync : un arbre local (~/repos) pour tous les depots des forges declarees
# dans ~/.config/repos/forges.conf. `repo <projet> [namespace]` clone si besoin
# puis s'y place ; la liste se rafraichit en arriere-plan, au plus 1 fois par jour.