You are not logged in.

#1 2010-10-05 11:37:43

chrispoole
Member
Registered: 2008-12-30
Posts: 121

Change http_proxy variable across all zsh sessions?

I have a laptop which goes from a connection with a http proxy to one without, so I have to change it constantly.

I can write a script with the line

export http_proxy='example.com:8080'

But it doesn't work across all sessions.

I use screen, with 5 or so zsh session 'tabs'.

Is there a way to have the variable set on a parent process to cascade down to child processes, or otherwise set it once, globally? (Ideally in a script that I can set to run automatically.)

Thanks guys.

(What I think I want is a global environment variable.)

Offline

#2 2010-10-05 11:50:16

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Change http_proxy variable across all zsh sessions?

If you put it in .zshrc, you have to source it in all the active zsh sessions.

Last edited by karol (2010-10-05 11:51:12)

Offline

#3 2010-10-05 11:57:59

chrispoole
Member
Registered: 2008-12-30
Posts: 121

Re: Change http_proxy variable across all zsh sessions?

If you put it in .zshrc, you have to source it in all the active zsh sessions.

True, but I change my proxy settings far more than I start sessions; I'd still have to enter

source ~/.zshrc

in each zsh session...

Offline

#4 2010-10-05 12:59:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Change http_proxy variable across all zsh sessions?

IIRC each shell instance has it's own execution environment set when you start that shell instance. You can

alias zz="source ~/.zshrc"

to make it quicker.

Offline

#5 2010-10-05 13:06:44

chrispoole
Member
Registered: 2008-12-30
Posts: 121

Re: Change http_proxy variable across all zsh sessions?

karol wrote:

IIRC each shell instance has it's own execution environment set when you start that shell instance. You can

alias zz="source ~/.zshrc"

to make it quicker.

That also works, but is there any way to script that?

(Sorry to be a pain, but surely there's a way to do this, to set this environment variable for all sessions at once.)

Offline

#6 2010-10-05 13:11:04

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Change http_proxy variable across all zsh sessions?

You can set environmental variable, but are you sure your shell will be aware of that? Try it out and see for yourself.
If you set it and start a new session, this will work but I don't know how to "update" the current ones.

Offline

#7 2010-10-05 22:44:14

dakt
Member
From: Croatia
Registered: 2010-10-04
Posts: 67

Re: Change http_proxy variable across all zsh sessions?

You can make an infinitive loop inside .zshrc which will setup env. var. like $http_proxy, every second. So once you edit it in one term. session it will be set up across all of them.

Offline

#8 2010-10-06 02:20:22

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: Change http_proxy variable across all zsh sessions?

Changing an environment variable will only be noticed by child processes. Changing the variable in one shell instance will not reflect in another.


neutral

Offline

Board footer

Powered by FluxBB