Some, but not all, command line tools such as
homebrew support SOCKS5 proxy intrinsically.
You can set the environment variable
ALL_PROXY in bash shell, type this:
You can also put above line to the end of
~/.bash_profile file, so every time the Terminal.app opens, proxy setting will take effect automatically.