Auto Set Proxy for Windows PowerShell, WSL and WSA
If you use Windows for Development, I highly recommend use Clash TUN mode or Router Proxy such as OpenClash or Surge.
Set system proxy on your Windows.
Install-Module -Name powershell-windows-autoproxy
Add the following to your PowerShell profile:
Import-Module powershell-windows-autoproxy
Download wsl-autoproxy.sh to your WSL home directory.
Add the following to your .bashrc
source ~/.wsl-autoproxy.sh
WARNING: If you are in Windows Insider Dev Channel, Windows will make auto-proxy for your WSL, in such case you cannot use Windows local proxy, because it will set 127.0.0.1 for your WSL. Please refer to How to use Clash on Linux
Please toggle your WSA's Developer mode in Windows Subsystem for Android -> Advanced settings -> Developer mode.
First time you have to allow adb to access your WSA. And everything will set automately.
WARNING: If you are in Windows Insider Dev Channel, the vEthernet (WSLCore) interface has been removed, which is used to proxy for WSA. I have no idea how to use Windows proxy for WSA then.
proxy
noproxy
There are two commands you can use.
Waiting for Linux user making bash-linux-autoproxy.