skip to content
ccdocs

cc switch

Switch your active project and configure your IDE.

Usage

cc switch [name] [flags]

Arguments

ArgumentDescription
nameProject name (tab-completable). If omitted, shows a picker with your 5 most recently used environments.

Flags

FlagDescription
-s, --silentSwitch without opening the IDE
-n, --newOpen the project in a new IDE window (auto-enabled in VSCode terminals)
-i, --ignoreIgnore saved config and re-discover the project from scratch
-e, --envSwitch directly to a named environment: cc switch --env staging

What It Does

  1. Looks up the project in the database
  2. If multiple environments exist, prompts you to choose one
  3. Checks if you've been on the previous project longer than your flag threshold — shows a summary if so
  4. Runs ~/.cc-cli/hooks/pre_switch if it exists
  5. Sets the environment as active (per-version slot in multi-version mode)
  6. Updates the editor's per-switch state (e.g. .vscode/settings.json — database, addons paths, modules, Python interpreter, ports) via registered IDE writers. launch.json is not touched on switch; debug templates picked up via ${config:cc.*} variable indirection. Run cc ide setup once to (re)write the templates.
  7. Checks out the configured git branch (single-repo mode only)
  8. Changes directory to the project path
  9. Opens the project in your IDE
  10. Triggers a background git fetch for 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
  11. Runs ~/.cc-cli/hooks/post_switch if 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_switch

Any 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"
fi

Environment Variables Available in Hooks

VariableDescription
CC_ENV_NAMEEnvironment name (e.g. acme_staging)
CC_PROJECT_NAMEProject name (e.g. acme)
CC_PROJECT_PATHAbsolute path to the project directory
CC_DATABASELinked database name
CC_BRANCHConfigured branch name
CC_VERSIONOdoo 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

On this page