How to set a proxy for the terminal in macOS?

On macOS, the terminal does not use a proxy by default.

If you want to request a URL via Curl or download a file via Wget using a SOCKS proxy instead of a VPN, follow this guide to make it happen.

For the current terminal session.

Run this command in terminal:
export ALL_PROXY=socks5://address:port

If you don't have a SOCKS proxy, get a free one now.

For all terminal sessions.

Open the file "~/.bashrc":
vim ~/.bashrc
Add this command into it and save it:
export ALL_PROXY=socks5://address:port

If you don't have a SOCKS proxy, get a free one now.

Test it on macOS.

Tested macOS version: Tahoe 26.4.1.
Test code:
curl "https://ipinfo.io"

Check if the IP in the JSON results matches the SOCKS proxy server.