π Cross-platform CLI tool for managing proxy environment variables
β
Cross-platform - Works on Windows, macOS, and Linux
β
Simple CLI - Easy-to-use commands for managing proxies
β
Persistent Config - Save proxy settings for reuse
β
NO_PROXY Support - Manage proxy bypass lists
β
Proxy Testing - Test connectivity and display IP information
β
Shell Integration - Optional shell functions for seamless usage
npm install -g @ryuyx/pvm# Set proxy
pvm set http://127.0.0.1:7890
# Enable proxy (shows commands to run)
pvm on
# Check status
pvm list
# Disable proxy
pvm offCheck current status:
pvm
pvm listSet proxy URL:
# Set both HTTP and HTTPS to the same URL
pvm set http://127.0.0.1:7890
# Set HTTP and HTTPS separately
pvm set --http http://127.0.0.1:7890 --https http://127.0.0.1:7891
# Set with NO_PROXY list
pvm set http://127.0.0.1:7890 --no-proxy "localhost,127.0.0.1,.local"Enable/Disable proxy:
pvm on # Shows commands to enable
pvm off # Shows commands to disableView configuration:
pvm config showSet specific values:
pvm config set http http://127.0.0.1:7890
pvm config set https http://127.0.0.1:7891
pvm config set both http://127.0.0.1:7890
pvm config set no-proxy "localhost,127.0.0.1"Manage NO_PROXY list:
# Add domain to NO_PROXY
pvm config add no-proxy .local
# Remove domain from NO_PROXY
pvm config rm no-proxy .localReset to defaults:
pvm config resetTest your proxy configuration and see detailed information:
# Test proxy connectivity and display IP information
pvm test
# Alias: doctor
pvm doctorThis command will:
- Show current proxy configuration
- Test direct internet connection (without proxy)
- Test proxy connectivity and latency
- Display your current IP address and location
- Compare latency between direct and proxy connections
- Provide troubleshooting tips if connection fails
Example output:
π§ͺ Testing proxy configuration...
Current Configuration:
HTTP Proxy: http://127.0.0.1:7890
HTTPS Proxy: http://127.0.0.1:7890
Status: β ENABLED
Testing direct connection (no proxy)...
β Connected directly
Latency: 245ms
IP: 183.251.239.27
Location: Beijing, China
Testing proxy connection (http://127.0.0.1:7890)...
β Proxy is reachable
Latency: 156ms
Overhead: -89ms (faster than direct!)
Exit IP: 104.16.249.249
Exit Location: San Francisco, United States
β IP successfully changed!
Since Node.js runs in a subprocess and cannot modify the parent shell's environment, you have the following options:
Simply run the install command to automatically add shell integration:
pvm installThis will:
- Detect your shell type (Bash, Zsh, or PowerShell)
- Add the integration function to your shell config file
- Enable
pvm onandpvm offto work automatically
Then reload your shell:
source ~/.bashrc # or ~/.zshrc for Zsh
# Or simply restart your terminalTo uninstall:
pvm uninstall# 1. Run this to see the commands
pvm on
# 2. Copy and paste the output commands into your shell
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
# ... etcIf you prefer to add the function manually, add this to your shell profile:
For Bash/Zsh (~/.bashrc or ~/.zshrc):
pvm() {
if [ "$1" = "on" ]; then
eval "$(command pvm on 2>/dev/null | grep -E '^(export|unset)')"
echo "β Proxy enabled"
elif [ "$1" = "off" ]; then
eval "$(command pvm off 2>/dev/null | grep -E '^(export|unset)')"
echo "β Proxy disabled"
else
command pvm "$@"
fi
}For PowerShell ($PROFILE):
function pvm {
if ($args[0] -eq "on") {
$commands = pvm-actual on 2>$null | Select-String '^\$env:|^Remove-Item'
$commands | ForEach-Object { Invoke-Expression $_ }
Write-Host "β Proxy enabled" -ForegroundColor Green
} elseif ($args[0] -eq "off") {
$commands = pvm-actual off 2>$null | Select-String '^\$env:|^Remove-Item'
$commands | ForEach-Object { Invoke-Expression $_ }
Write-Host "β Proxy disabled" -ForegroundColor Red
} else {
pvm-actual @args
}
}
# Rename the actual command
Set-Alias -Name pvm-actual -Value pvm.cmdThen reload your shell:
source ~/.bashrc # or ~/.zshrcNow you can use:
pvm on # Actually enables proxy
pvm off # Actually disables proxy- Configuration Storage: Settings are saved to a config file using the conf library
- Environment Variables: Sets HTTP_PROXY, HTTPS_PROXY, and NO_PROXY (both uppercase and lowercase)
- Cross-platform: Automatically detects shell type and generates appropriate commands
Config is stored at:
- Windows:
%APPDATA%\proxy-manager-nodejs\Config\config.json - macOS:
~/Library/Preferences/proxy-manager-nodejs/config.json - Linux:
~/.config/proxy-manager-nodejs/config.json
| Command | Description |
|---|---|
pvm |
Show current status |
pvm on |
Display commands to enable proxy |
pvm off |
Display commands to disable proxy |
pvm list |
Show configuration and status |
pvm set <url> |
Set proxy URL |
pvm test |
Test proxy connectivity and display IP info |
pvm install |
Auto-install shell integration |
pvm uninstall |
Remove shell integration |
pvm config show |
Show configuration |
pvm config set <key> <value> |
Set config value |
pvm config add no-proxy <item> |
Add to NO_PROXY list |
pvm config rm no-proxy <item> |
Remove from NO_PROXY list |
pvm config reset |
Reset to defaults |
This tool manages the following environment variables:
http_proxy/HTTP_PROXY- HTTP proxy URLhttps_proxy/HTTPS_PROXY- HTTPS proxy URLno_proxy/NO_PROXY- Comma-separated list of hosts to bypass proxy
Contributions are welcome! Please feel free to submit a Pull Request.
MIT Β© Liu Yuxuan
Made with β€οΈ for developers who need proxy management