的Mac OS X 10.9 - 设置永久的环境变量 [英] Mac OS X 10.9 - setting permanent environment variables
问题描述
我设置一个永久的环境变量(即,一个不需要出口,我开始一个新的终端会话每次)在Mac OS X 10.9怎么办?我已经找到了一些答案有关修改我的的.bash_profile
和 .profile文件
,但是没有这些选择似乎工作作为永久的解决方案 - 只是暂时的。我想设置的变量是 MULE_HOME
。我有以下线在我的bash的个人资料:
How do I set a permanent environment variable (i.e. one that does not need exporting every time I start a new Terminal session) in Mac OS X 10.9? I've found a number of answers about modifying my .bash_profile
and .profile
, however neither of these options seem to work as permanent solutions - only temporary. The variable I'm trying to set is MULE_HOME
. I have the following line in my bash profile:
export MULE_HOME=$(/opt/mule-standalone-3.4.0)
然而,当我启动终端,我得到以下行(不知道这是正常的行为):
However, when I start Terminal I get the following line (not sure if this is normal behaviour?):
-bash: /opt/mule-standalone-3.4.0: is a directory
和运行一个简单的 ENV
命令返回以下内容:
And running a simple env
command returns the following:
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/fc/68bqp4jj411gynj5qvwhq6z1shs1fy/T/
Apple_PubSub_Socket_Render=/tmp/launch-xKtkql/Render
TERM_PROGRAM_VERSION=326
TERM_SESSION_ID=E97BFE4B-AF85-4933-B252-0883CC085349
USER=dan
SSH_AUTH_SOCK=/tmp/launch-rEmTWW/Listeners
__CF_USER_TEXT_ENCODING=0x730C85DE:0:0
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
__CHECKFIX1436934=1
PWD=/Users/dan
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
LANG=en_GB.UTF-8
MULE_HOME=
SHLVL=1
HOME=/Users/dan
LOGNAME=danwiseman
_=/usr/bin/env
为了解决这个问题,我现在不必键入出口MULE_HOME = /选择/骡子独立-3.4.0
每次我开始一个新的终端会话时间其中,虽然不费劲,有点不方便。我在做什么错在这里引起该变量只能临时设置?先谢谢了。
In order to get around this I'm currently having to type export MULE_HOME=/opt/mule-standalone-3.4.0
every time I start a new Terminal session which, whilst not strenuous, is a little inconvenient. What am I doing wrong here that is causing the variable to only be set temporarily? Thanks in advance.
推荐答案
删除该 $(...)
位,这将尝试在括号内执行命令并设置 $ MULE_HOME
来不管它产生。在你的情况 /opt/mule-standalone-3.4.0
是不是可执行文件,因此错误你得到。
Drop the $(...)
bit, which would attempt to execute the command within the brackets and set $MULE_HOME
to whatever it produces. In your case /opt/mule-standalone-3.4.0
is not an executable, hence the error you are getting.
export MULE_HOME=/opt/mule-standalone-3.4.0
<击>,并使用〜/ .bashrc中
不是〜/ .bash_profile中
。击>
编辑:看来的意见是,你应该设置在你的〜/ .bash_profile中
脚本环境变量,而不是〜/ .bashrc中
脚本。
It seems opinion is that you should set environment variables in your ~/.bash_profile
script, and not ~/.bashrc
script.
这篇关于的Mac OS X 10.9 - 设置永久的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!