I would like to set environment variables for the scope of a terminal session.
Eg, the user would open a terminal, type something like setproject <project_name>
and it would export an environment variable PROJECT
. When they close the terminal, the variable setting is lost. What was impressive with this system was that it would know what project name was valid and what wasn’t. I’ve worked at places that have done this quite well and I’m wondering how it’s done.
I’d prefer the user not have to type source setproject <project_name>
and I also wanted to check if the project they specified was valid or not.
I’ve written something in python, which checks the validity of a project name (against a yaml config file), and passes it on to a bash script, but it doesn’t really work (the environment variable isn’t properly set. It’s set, but only for the scope of the python script)
So, how’d I do this? Are there any good examples of what I’m looking for online?