Skip to content

Instantly share code, notes, and snippets.

@tongyul
Created March 3, 2025 15:38
Show Gist options
  • Save tongyul/acae67e946bd7728e6294ad977009918 to your computer and use it in GitHub Desktop.
Save tongyul/acae67e946bd7728e6294ad977009918 to your computer and use it in GitHub Desktop.
Shell script that runs command with network proxy variables
#!/bin/bash -e
HELP_STR="\
Usage:
proxied # prints this message
proxied _proxy_ # prints sh snippet that sets _proxy_
proxied _proxy_ _cmd_... # runs _cmd_ with _proxy_
Environment variables that are affected:
- ALL_PROXY
- http_proxy
- https_proxy
"
case "$#" in
0)
printf '%s' "$HELP_STR"
;;
1)
echo "export ALL_PROXY='$1';"
echo "export http_proxy='$1';"
echo "export https_proxy='$1';"
;;
*)
(eval "$("$SHELL" "$0" "$1")" && shift && "$@";)
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment