Skip to content

A cli tool to append system proxy settings into your terminal

License

Notifications You must be signed in to change notification settings

Cookee24/termproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TermProxy

A simple cli tool for setting up proxy environment variables. Automatically reads the proxy settings from the system and sets them up in the environment variables.

Usage

1. Install

TODO

2. Set up

Bash

Add the following line to your .bashrc or .bash_profile:

eval "$(termproxy init bash)"
Cmd
  1. Add a string value to the registry key:

    • Apply .cmdrc.cmd to all users:
    reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor" /v "AutoRun" /t REG_SZ /d "if exist %USERPROFILE%\.cmdrc.cmd %USERPROFILE%\.cmdrc.cmd"
    • Or apply to the current user only:
    reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor" /v "AutoRun" /t REG_SZ /d "if exist %USERPROFILE%\.cmdrc.cmd %USERPROFILE%\.cmdrc.cmd"
  2. Add the following content to the file %USERPROFILE%\.cmdrc.cmd:

@echo off && termproxy init cmd -o "%TEMP%/proxy.cmd" && call "%TEMP%/proxy.cmd" && @echo on
Elvish

Add the following line to your ~/.elvish/rc.elv:

eval (termproxy init elvish)
Fish

Add the following line to your ~/.config/fish/config.fish:

termproxy init fish | source
Ion

Add the following line to your ~/.config/ion/initrc:

eval $(termproxy init ion)
Nu
  1. Add the following line to $nu.env-path:
# Create `.cache` directory first if it doesn't exist
termproxy init nu -o ~/.cache/__proxy.nu
  1. Add the following line to your $nu.config-path:
use ~/.cache/__proxy.nu
PowerShell

Add the following line to your $PROFILE:

Invoke-Expression (termproxy init powershell | Out-String)
Tcsh

Add the following line to your ~/.cshrc:

eval `termproxy init tcsh`
Xonsh

Add the following line to your ~/.xonshrc:

execx($(termproxy init xonsh))
Zsh

Add the following line to your ~/.zshrc:

eval "$(termproxy init zsh)"

Limitations

  1. There is no real standard for the no_proxy environment variable. So we follow the behavior of curl.
    • Windows: wildcard domains and wildcard ips on windows will be converted into stripped domains and CIDRs, and wildcard forms like www.*.com, 192.168.*.1 might not work.

Tips

  1. Using sudo

If you are using sudo to run a command, you can use the -E option to preserve the environment variables, or you can specify the environment variables you want to preserve in /etc/sudoers:

Defaults env_keep += "http_proxy https_proxy all_proxy no_proxy"

TODOs

  • Add support for macos
  • Publish to scoop, brew and aur.

About

A cli tool to append system proxy settings into your terminal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages