Directory based environment variable scope - how to implement?

前端 未结 7 516
庸人自扰
庸人自扰 2021-02-04 00:03

I have a set of tools which I need to pass parameters depending on the project I\'m working on. I\'d like to be able to automatically set a couple of environment variables based

7条回答
  •  一整个雨季
    2021-02-04 00:34

    This is not something that is directly supported with the built-in features of bash or any other common shell. However, you can create your own "cd" command that will do whatever you want. For example, you could alias cd to do the cd and then run a special script (eg: ~/bin/oncd). That script could look up the new directory in a database and run some commands, or see if there's a special file (eg: .env) in the directory and load it, etc.

提交回复
热议问题