cc switch
Switch your active project and configure your IDE.
Usage
cc switch [name] [flags]Arguments
| Argument | Description |
|---|---|
name | Project name (tab-completable). If omitted, shows a picker with your 5 most recently used environments. |
Flags
| Flag | Description |
|---|---|
-s, --silent | Switch without opening the IDE |
-n, --new | Open the project in a new IDE window (auto-enabled in VSCode terminals) |
-i, --ignore | Ignore saved config and re-discover the project from scratch |
-e, --env | Switch directly to a named environment: cc switch --env staging |
What It Does
- Looks up the project in the database
- If multiple environments exist, prompts you to choose one
- Checks if you've been on the previous project longer than your flag threshold — shows a summary if so
- Runs
~/.cc-cli/hooks/pre_switchif it exists - Sets the environment as active (per-version slot in multi-version mode)
- Updates the editor's per-switch state (e.g.
.vscode/settings.json— database, addons paths, modules, Python interpreter, ports) via registered IDE writers.launch.jsonis not touched on switch; debug templates picked up via${config:cc.*}variable indirection. Runcc ide setuponce to (re)write the templates. - Checks out the configured git branch (single-repo mode only)
- Changes directory to the project path
- Opens the project in your IDE
- Triggers a background
git fetchfor odoo/enterprise/design-themes if auto-fetch is enabled and the interval has elapsed (default 24h) — runs silently in the background, does not block the switch - Runs
~/.cc-cli/hooks/post_switchif it exists
Switch Hooks
You can run custom scripts before and after every switch by placing executables at:
~/.cc-cli/hooks/pre_switch
~/.cc-cli/hooks/post_switchAny line printed to stdout is eval'd in the parent shell — this is how hooks can activate virtualenvs or export environment variables:
#!/bin/bash
# ~/.cc-cli/hooks/post_switch — activate a project-specific venv
if [ -f "$CC_PROJECT_PATH/.venv/bin/activate" ]; then
echo "source $CC_PROJECT_PATH/.venv/bin/activate"
fiEnvironment Variables Available in Hooks
| Variable | Description |
|---|---|
CC_ENV_NAME | Environment name (e.g. acme_staging) |
CC_PROJECT_NAME | Project name (e.g. acme) |
CC_PROJECT_PATH | Absolute path to the project directory |
CC_DATABASE | Linked database name |
CC_BRANCH | Configured branch name |
CC_VERSION | Odoo version (e.g. 19.0) |
Hooks have a 30-second timeout. Failures are logged as warnings but do not abort the switch.
Examples
cc switch acme # switch to acme, open IDE
cc switch acme -s # switch silently (no IDE open)
cc switch acme -n # open in new window
cc switch acme -i # re-discover and reconfigure acme
cc switch # show recent envs picker
cc switch --env staging # switch directly to "staging" environment