according to above ideas, I created a shell script that to make a proxy environment for composer.
#!/bin/bash
export HTTP_PROXY=http://127.0.0.1:8888/
export HTTPS_PROXY=http://127.0.0.1:8888/
zsh # you can alse use bash or other shell
This piece of code is in a file named ~/bin/proxy_mode_shell
and it will create a new zsh
shell instance when you need proxy. After update finished, you can simply press key Ctrl+D
to quit the proxy mode.
add export PATH=~/bin:$PATH
to ~/.bashrc
or ~/.zshrc
if you cannot run proxy_mode_shell
directly.