Smart ProfilesAutomatically select a VS Code profile when you open a project, using Git remote hosts, folder patterns, project files, or standalone file extensions. For example, show your GitHub tools in GitHub projects and your self-hosted forge's tools in work projects. New repositories that match your rules need no individual setup. Demonstration
Recorded in VS Code with the real extension and fictional repositories. Changing one repository's remote selects GitHub, then Work Git; an unmatched host keeps Work Git active. Different profile colors make the switches visible. You choose each profile's extensions and Activity Bar layout yourself. Getting started
There are no built-in host mappings or profile names. This example uses a public host and a fictional self-hosted instance; replace the names with your own:
The profile names must exactly match existing profiles. The extension does not create profiles, install other extensions, or authenticate with your Git host. Profile switching can restart extensions or reopen the current workspace. Match folders by patternFolder rules can cover whole groups of current and future repositories:
Folders are matched against their absolute paths. Use forward slashes even on Windows. A leading ~ expands to your home directory.
Matching is case-insensitive on Windows and macOS, and case-sensitive on Linux. Braces, brackets, and other regex syntax are literal characters in folder and host patterns. Project files and standalone filesUse files to require project markers. Every file pattern in a rule must find at least one file; patterns are relative to the repository or workspace folder. These use VS Code file glob syntax. The extension searches filenames without reading their contents and excludes .git and node_modules directories.
Standalone file rules apply only when no workspace folder is open and a saved local file is active. Suffixes are case-insensitive; .d.ts is supported. Keep standalone file rules separate from folder, host, and project-file rules. How selection works
Hosts are compared locally from URLs such as HTTPS, SSH, and scp-style Git remotes. Custom ports do not affect host matching. SSH aliases are matched as written in the remote; SSH configuration and Git URL rewrites are not expanded. Local filesystem remotes and unrecognized transports have no known host. Use gitHostProfiles.remoteNames to restrict which remotes count:
An empty list, the default, considers every remote. Restricting the list deliberately ignores other destinations. Commands and settingsCommands are available through the Command Palette under Smart Profiles:
The status bar item opens the explanation. Pause takes precedence over the Apply command; resume switching first.
These settings apply across profiles and cannot be supplied by workspace or repository settings. They are excluded from Settings Sync by default. Keep your private hosts, paths, and profile names in your user settings, outside this repository. Settings Sync preferences can override the exclusion. Invalid rules stop selection and show a warning. Use the explanation command after correcting them. Local installation and updatesBuild the reviewed source with Node.js 24 or newer:
Choose Extensions: Install from VSIX... and select the file under artifacts/. Disable auto-update for this extension in its extension management menu. VS Code can update a sideloaded extension if a Marketplace item later uses the same publisher and extension ID. A local VSIX is not, by itself, a guarantee against future automatic updates. The publisher ID is Privacy and compatibilityThe extension has no third-party runtime dependencies, telemetry, network requests, shell commands, or credential requirements. It uses the built-in Git extension's repository information. Decision logs omit remote URLs and paths; stored decision markers are hashes. VS Code extensions still run with VS Code's permissions. Reviewing this source and controlling updates remain necessary trust decisions. Automatic selection runs only in trusted local desktop workspaces. Remote SSH, WSL, containers, and virtual workspaces are not supported in this version. VS Code does not provide a complete public profile-management API. The small compatibility adapter reads profile names from VS Code's local catalog and uses its profile-opening commands. It never writes that catalog. Changes to VS Code's storage layout or commands may require an extension update. When the adapter cannot find a profile or supported command, it reports the problem instead of creating profiles or invoking an external program. DevelopmentRead the implementation walkthrough for architecture diagrams, a worked example, and a file-by-file and function-by-function tour. See CONTRIBUTING.md for tests, packaging, and the publication checklist. Inspiration and licenseInspired by VSCode Profile Automatic Switcher and its rule-based approach to folders, project files, and file extensions. This is an independent implementation; no source code was copied. Licensed under GPL-3.0-only. |
