I’m trying to write a script that will allow me to set a bunch of environment variables in my env.
What I’m used to do is:
source ./script
But now I want my script to be in the PATH variable so I can call it from everywhere I want.
But calling it like that:
script
Will open a new shell and set the variables in the new shell, once the script is finished executing, I’d lose everything.
So I was wondering how I could do this.
Maybe you should use an
alias.Say your environment variables are in the file
/path/to/stuff/my_env, just add an aliasThen you just need to issue
my_envand you’ll be done!What you’re trying to achieve can’t be done from within a script, unless your script launches a new
bashcommand, but that’s a bit awkward!