Manage Auto-Detect
Manage gpx configuration settings, such as enabling or disabling the auto-detect feature.
Usage
gpx config <get|set> <key> [value]
Available Keys
| Key | Description | Default |
|---|---|---|
auto-detect | Automatically switch local profile when entering a repo | false |
Examples
Check a setting
gpx config get auto-detect
Expected output:
auto-detect = false
Change a setting
gpx config set auto-detect true
How Auto-Detect Works
When auto-detect is enabled, gpx automatically switches your local profile whenever you cd into a repository that uses a gpx SSH host alias (e.g., github.com-work) in its remote URL.
Setup
- Enable auto-detect:
gpx config set auto-detect true
- Initialize shell hooks (if not already done):
gpx init --shell zsh
What happens behind the scenes
When you move into a repository:
cd ~/work/company-repo
The shell hook fires and does the following:
- Checks the repo's remote URL (e.g.,
git@github.com-work:org/repo.git). - Extracts the profile name ("work") from the SSH host alias.
- Automatically sets the local profile to
work(equivalent to runninggpx use work --local). - Updates the terminal prompt badge.
NOTE
Auto-detect only changes the local profile for the current repository. Your global profile remains unchanged.
Auto-detect and Commit Guard
Auto-detect and Commit Guard are designed to work perfectly together:
- Auto-detect ON: The correct local profile is set automatically when you enter a repo. The Commit Guard silently verifies the match and lets your commits through.
- Auto-detect OFF: You must manually switch profiles with
gpx use <name> --local. If you forget, the Commit Guard catches the mismatch and blocks the commit, keeping your repository safe.
Related commands
gpx init- Install the shell hooks required for auto-detect to work.