[英]Use Environment Variables in IntelliJ IDEA Bash Script
Goal: to run a bash script as the method for builds/runs, by building a runConfiguration that calls the bash script. 目标:通过构建调用bash脚本的runConfiguration来运行bash脚本作为构建/运行方法。
I'm using the BashSupport plugin in the latest version of IntelliJ IDEA. 我正在最新版本的IntelliJ IDEA中使用BashSupport插件。 I am trying to reference system environment variables from a shell script that is called from a runConfiguration, but I can't pull in system environment variables, unless I manually specify the environment variables in the runConfiguration's XML, which is not an option.
我试图从从runConfiguration调用的shell脚本中引用系统环境变量,但是除非我在runConfiguration的XML中手动指定环境变量,否则就不能提取系统环境变量,这是不可行的。 I want to be able to pull variables directly from the system.
我希望能够直接从系统中提取变量。 I have tried putting environment variables in /etc/environment and .bashrc and .zshrc.
我尝试将环境变量放在/ etc / environment和.bashrc和.zshrc中。
Any advice would be greatly appreciated! 任何建议将不胜感激!
OS: Ubuntu-based 操作系统:基于Ubuntu
Thank you @CrazyCoder! 谢谢@CrazyCoder! That was definitely it.
就是这样。 Turns out that after a system restart (not just an IntelliJ restart), IntelliJ was able to pick up the variables I put in
/etc/environment
. 事实证明,在系统重新启动(不仅是IntelliJ重新启动)之后,IntelliJ能够提取我在
/etc/environment
输入的变量。 Didn't even need to add them to ~/.profile
. 甚至不需要将它们添加到
~/.profile
。 Thanks for doing the research! 感谢您的研究!
Another solution: 另一个解决方案:
@See .bashrc file @See .bashrc文件
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
#....
It is troublesome to set environment variables from the Edit Configuration of Intelli-J editing. 从Intelli-J编辑的“编辑配置”中设置环境变量很麻烦。 I would like to read it from a file if possible.
如果可能的话,我想从文件中读取它。
So I did it like this. 所以我这样做了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.