How to export a shell variable to all sessions?
bash, shell
Solution
You can set up your sessions to keep rereading a file on disk by setting a trap on DEBUG in your `.bashrc`:
trap 'source ~/.myvars' DEBUG
If you leave a terminal A open, run `echo VAR=42 >> ~/.myvars` in terminal B, then switch back to terminal A and `echo $VAR`, it'll "magically" be set.
Problem
I would like to know is there a way to export my shell variable to all sessions in the system (not only the current session). I'm not looking to set it in .bashrc file as the shell variable is a dynamic one it changes time to time.