bash 如何将类路径永久添加到我的 Mac 终端?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8629948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:13:01  来源:igfitidea点击:

How can I permanently add a class path to my Mac terminal?

macosbashshellterminalclasspath

提问by Sheehan Alam

I want to set my path permanently for the following directory:

我想为以下目录永久设置我的路径:

/Users/syalam/Library/android-sdk-mac_86/platform-tools

Not sure how to do it from the terminal. I tried:

不确定如何从终端执行此操作。我试过:

export PATH=$PATH:/Users/syalam/Library/android-sdk-mac_86/platform-tools

but it only works temporarily. After I close my shell it no longer exists.

但它只能暂时起作用。在我关闭我的外壳后,它不再存在。

采纳答案by fge

Just add this entry to your CLASSPATHenvironment variable in your .bashrc:

只需将此条目添加到您的CLASSPATH环境变量中.bashrc

export CLASSPATH="/Users/syalam/Library/android-sdk-mac_86/platform-tools:$CLASSPATH"

回答by Ravi G

http://blog.just2us.com/2011/05/setting-path-variable-in-mac-permanently/

http://blog.just2us.com/2011/05/setting-path-variable-in-mac-permanently/

Set permanently for a user:

为用户永久设置:

Edit the user's bash profile (replace USERNAME)

编辑用户的 bash 配置文件(替换 USERNAME)

pico ~USERNAME/.bash_profile

Insert (or edit) this line

插入(或编辑)这一行

PATH=$PATH:/my/new/path/

Press ctrl-x, then ctrl-y, to save the file.

按 ctrl-x,然后按 ctrl-y,保存文件。

Done.

完毕。

Set for all users

为所有用户设置

sudo pico /etc/paths

Enter your superuser password to edit, and insert or edit this link

输入您的超级用户密码进行编辑,并插入或编辑此链接

PATH=$PATH:/my/new/path/

That's it! Enjoy your path!

就是这样!享受你的道路!

回答by Nijil Nair

I tried different things, I could only set temporarily. Atlast tried this and got worked

我尝试了不同的东西,我只能暂时设置。Atlast 尝试了这个并开始工作

echo 'export PATH=$PATH:/User/Documents/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/User/Documents/adt-bundle-mac-x86_64-20140702/sdk/tools' >> ~/.bash_profile

this will set the path permanently.

这将永久设置路径。

/User/Documents/adt-bundle-mac-x86_64-20140702/sdkthis is my Android SDK path

/User/Documents/adt-bundle-mac-x86_64-20140702/sdk这是我的 Android SDK 路径

回答by Navaneetha Krishnan P

Set classpathin your bashprofileand close the terminal and restart it will work sure

设置classpathbashprofile靠近终端并重新启动它肯定会工作

Do the following:

请执行下列操作:

1- vi .bash_profile {open in terminal} home directory
2- add this line export CLASSPATH=$CLASSPATH:/{//directory//}

1- vi .bash_profile {open in terminal} 主目录
2- 添加这一行 export CLASSPATH=$CLASSPATH://{//directory//}