Reputation: 17210
I have many opened terminals. Now I want to set a environment variable and wish the environment variable can effective in all opened terminal(do'nt need lgout the shell and login again or any other extra command such as source to make it effective) not just the terminal in which I set the environment variable.
Is there any ideas?
Upvotes: 0
Views: 4310
Reputation: 241868
It depends on the type of shell you use. For example, in bash, you can
~/.env
which will contain the settings.in your ~/.bashrc
, tell each terminal to source the file at each prompt:
PROMPT_COMMAND='. ~/.env'
If you change the .env
file (e.g. try echo TEST=1 > ~/.env
), then after pressing Enter in any terminal that uses the new .bashrc
, echo $TEST
will produce 1
.
Upvotes: 5