How should I export http_proxy variable?
bash, networking, proxy
Solution
Back in the day I was also sick of setting and then unsetting the proxy settings after my work was done. I always wished if there was a command simple command to do the set and unset function for me.
Then I figured that if I create a new function in my .bashrc I can call it from the command line by using the bash-tab-completion. Saves even more time.
This is what I did:
$ vi ~/.bashrc
function setproxy() {
export {http,https,ftp}_proxy='http://proxy-serv:8080'
}
function unsetproxy() {
unset {http,https,ftp}_proxy
}
$ . ~/.bashrc
Now I just do:
$ setproxy
or
$ setp<TAB> and <ENTER>
and it sets the proxy for me. Hope this helps.
Problem
I'm trying to write a simple script that will set proxy settings. Actually I just need to export `http_proxy ftp_proxy https_proxy ...` variables with `export` command. But it's not working when I run it manually from the shell because `export` affect only current shell and subshells, but no others. Also I don't want to call it from `.bashrc` because it's not my default proxy settings. So how should I export `http_proxy` variable to make effect globally?