Shell Integration
scoop uses a shell wrapper pattern (like pyenv) where the CLI outputs shell code that gets evaluated by the shell.
How It Works
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ User runs │ --> │ CLI outputs │ --> │ Shell evals │
│ scoop use │ │ export ... │ │ the output │
└─────────────┘ └─────────────┘ └─────────────┘
The scoop shell function wraps the CLI binary:
scoop() {
case "$1" in
use)
command scoop "$@"
eval "$(command scoop activate "$name")"
;;
activate|deactivate|shell)
eval "$(command scoop "$@")"
;;
*)
command scoop "$@"
;;
esac
}
Setup
Zsh
echo 'eval "$(scoop init zsh)"' >> ~/.zshrc
source ~/.zshrc
Bash
echo 'eval "$(scoop init bash)"' >> ~/.bashrc
source ~/.bashrc
Fish
echo 'eval (scoop init fish)' >> ~/.config/fish/config.fish
source ~/.config/fish/config.fish
Auto-Activation
When enabled, scoop automatically activates environments based on version files.
Zsh: Uses chpwd hook (runs on directory change)
autoload -Uz add-zsh-hook
add-zsh-hook chpwd _scoop_hook
Bash: Uses PROMPT_COMMAND
PROMPT_COMMAND="_scoop_hook;$PROMPT_COMMAND"
Fish: Uses --on-variable PWD event handler
function _scoop_hook --on-variable PWD
# Check for version file and activate/deactivate
end
The hook checks for version files and activates/deactivates accordingly.
Version Resolution Priority
scoop checks these sources in order (first match wins):
| Priority | Source | Set by |
|---|---|---|
| 1 | SCOOP_VERSION env var | scoop shell |
| 2 | .scoop-version file | scoop use |
| 3 | .python-version file | pyenv compatibility |
| 4 | ~/.scoop/version file | scoop use --global |
The “system” Value
When any source contains the value system, scoop deactivates the current virtual environment and uses the system Python.
scoop use system # Write "system" to .scoop-version
scoop shell system # Set SCOOP_VERSION=system (this terminal only)
Environment Variables
| Variable | Description | Default |
|---|---|---|
SCOOP_HOME | Base directory | ~/.scoop |
SCOOP_VERSION | Override version (highest priority) | (unset) |
SCOOP_NO_AUTO | Disable auto-activation | (unset) |
SCOOP_ACTIVE | Currently active environment | (set by scoop) |
SCOOP_RESOLVE_MAX_DEPTH | Limit parent directory traversal | (unlimited) |
Disable Auto-Activation
export SCOOP_NO_AUTO=1
Custom Home Directory
export SCOOP_HOME=/custom/path
Network Filesystem Optimization
For slow network filesystems (NFS, SSHFS), limit directory traversal depth:
# Only check current directory and up to 3 parents
export SCOOP_RESOLVE_MAX_DEPTH=3
# Only check current directory (fastest)
export SCOOP_RESOLVE_MAX_DEPTH=0
Using with pyenv
Add scoop after pyenv in your shell config:
# ~/.zshrc
eval "$(pyenv init -)" # 1. pyenv first
eval "$(scoop init zsh)" # 2. scoop second (takes precedence)
Tab Completion
Shell integration includes completion for:
- Commands and subcommands
- Environment names
- Python versions
- Command options
Completion is automatically enabled by scoop init.
Supported Shells
| Shell | Status |
|---|---|
| Zsh | Full support (auto-activation, completion) |
| Bash | Full support (auto-activation, completion) |
| Fish | Full support (auto-activation, completion) |
| PowerShell | Planned (P3) |