From The Compiler, 8 Years ago, written in Bash.
Embed
  1. #!/bin/bash
  2. declare -A urls
  3.  
  4. urls['ziproxy']="username:passwrd@localhost:9001"
  5. urls['ssh']='localhost:8123'
  6.  
  7. set_proxy() {
  8.         proxy="${urls[$1]}"
  9.         if [[ -z "$proxy" ]]; then
  10.                 echo "Proxy $1 is unknown!"
  11.                 exit 1
  12.         fi
  13.         dwb -x "local_set proxy true ;; local_set proxy-url $proxy"
  14. }
  15.  
  16. unset_proxy() {
  17.         dwb -x "local_set proxy false ;; local_set proxy-url NULL"
  18. }
  19.  
  20. if (( $# != 1 )); then
  21.         echo "Usage: $0 <proxyname>"
  22.         exit 1
  23. fi
  24.  
  25. case $1 in
  26.         "off") unset_proxy ;;
  27.         *) set_proxy "$1" ;;
  28. esac