ProxyTool is a simple command-line utility for setting and managing proxy settings for npm, Git, and system environment variables on Windows and VSCode using PowerShell. This tool helps you configure and unset proxies with ease, allowing you to manage your network settings directly from your terminal.
- Set Proxy: Configure HTTP and HTTPS proxy for npm, Git, and environment variables with a single command.
- Unset Proxy: Remove proxy settings from npm, Git, and environment variables.
- Check Proxy Status: View the current proxy settings for npm, Git, and system environment variables.
You can install ProxyTool globally from npm to use it on your system.
npm install -g @harshitnpm033/proxytoolTo set a proxy for npm, Git, and environment variables, simply run:
proxytool set --http http://<your-proxy>:<port>This will:
- Write the proxy settings to a PowerShell script (
.proxyenv.ps1). - Set npm and Git proxy settings.
- Provide instructions to run the script to apply the environment variables to your terminal session.
If you're a student of IIIT Allahabad, the default proxy (http://172.31.2.4:8080) is already hardcoded. To set the proxy, just run:
proxytool setThis command will automatically set the proxy for npm, Git, and environment variables without needing to specify the proxy URL. But you will still need to login with your credentials in the browser once.
To remove the proxy settings for npm, Git, and environment variables, run:
proxytool unsetThis will:
- Remove the proxy settings from npm and Git.
- Delete the
.proxyenv.ps1file, if it exists.
To view the current proxy settings, run:
proxytool statusThis will display:
- npm proxy status
- git proxy status
- Environment proxy status
To use ProxyTool effectively, you may need to change your PowerShell execution policy to allow script execution. The default policy on Windows may block the running of scripts.
-
Check current execution policy:
Open PowerShell and run:
Get-ExecutionPolicyIf the result is Restricted, you'll need to change it.
-
Set Execution Policy:
To allow local scripts to run, set the execution policy to RemoteSigned by running the following command in Administrator mode:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
This will allow locally created scripts to run and require downloaded scripts to be signed by a trusted publisher.
-
Run the Script:
After setting the execution policy, apply the proxy settings to your current PowerShell session by running:
. $env:USERPROFILE\proxyenv.ps1
If you notice that npm config get proxy returns null or undefined, it's possible that npm was not correctly configured. Ensure that the proxy URL is set by checking the .npmrc file, and manually updating it if necessary:
npm config set proxy http://<your-proxy>:<port>
npm config set https-proxy http://<your-proxy>:<port>If you'd like to contribute to ProxyTool, feel free to submit issues or pull requests. Here's how you can contribute:
- Fork the repository.
- Clone your fork to your local machine.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -am 'Add feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
This project is licensed under the ISC License.
Let me know if you'd like any further changes!