基于目录的环境变量的作用域 - 如何实现? [英] Directory based environment variable scope - how to implement?

查看:173
本文介绍了基于目录的环境变量的作用域 - 如何实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组的,我需要传递依赖于我的工作项目参数的工具。我想能够自动设置基于当前目录中的几个环境变量。所以,当我在目录之间切换时,我常用的包膜增值经销商也将发生改变。例如:

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 on the current directory. So when I switched between directories, my commonly used env vars would also change. Example:

让的当前目录是foo,因此,如果我做的:

Let's current directory is foo, thus if I do:

~/foo$ ./myscript --var1=$VAR1

VAR1会有一些基于富价值。

VAR1 would have some foo based value.

然后,让我们说我切换到吧目录。如果我做的:

Then, let's say I switched to bar directory. If I do:

~/bar$ ./myscript --var1=$VAR1

VAR1现在应该有一些基于价值吧。

VAR1 should now have some bar based value.

这可能吗?怎么样?

推荐答案

ondir 计划让你指定的动作,当你进入运行,并离开目录在终端

the ondir program lets you specify actions to run when you enter and leave directories in a terminal

这篇关于基于目录的环境变量的作用域 - 如何实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆