macos 在mac上编辑PATH变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7703041/
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-10-21 08:30:23  来源:igfitidea点击:

editing PATH variable on mac

macos

提问by coure2011

How to edit PATH variable on mac (Lion). I cannot find any file where I can add paths. can someone guide me about it?

如何在 mac (Lion) 上编辑 PATH 变量。我找不到任何可以添加路径的文件。有人可以指导我吗?

Whats the file name? .profile or .bash_profile???

文件名是什么?.profile 或 .bash_profile ???

and where I can find it? I have tried

我在哪里可以找到它?我努力了

echo 'export PATH=/android-sdk/tools:$PATH' >> ~/.profile

回答by Ryan Allen

Edit /etc/paths. Then close the terminal and reopen it.

编辑/etc/paths。然后关闭终端并重新打开它。

$ sudo vi /etc/paths

Note: each entry is seperated by line breaks.

注意:每个条目由换行符分隔。

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

回答by can.

Based on my own experiences and internet search, I find these places work:

根据我自己的经验和互联网搜索,我发现这些地方有效:

/etc/paths.d

/etc/paths.d

~/.bash_profile

~/.bash_profile

Note that you should open a new terminal window to see the changes.

请注意,您应该打开一个新的终端窗口以查看更改。

You may also refer to this this question

你也可以参考这个这个问题

回答by MasterCassim

You could try this:

你可以试试这个:

  1. Open the Terminal application. It can be found in the Utilities directory inside the Applications directory.
  2. Type the following: echo 'export PATH=YOURPATHHERE:$PATH' >> ~/.profile, replacing "YOURPATHHERE" with the name of the directory you want to add. Make certain that you use ">>" instead of one ">".
  3. Hit Enter.
  4. Close the Terminal and reopen. Your new Terminal session should now use the new PATH.
  1. 打开终端应用程序。它可以在 Applications 目录内的 Utilities 目录中找到。
  2. 键入以下内容:echo 'export PATH=YOURPATHHERE:$PATH' >> ~/.profile,将“YOURPATHHERE”替换为要添加的目录的名称。确保使用“>>”而不是“>”。
  3. 按回车键。
  4. 关闭终端并重新打开。您的新终端会话现在应该使用新的 PATH。

-> http://keito.me/tutorials/macosx_path

-> http://keito.me/tutorials/macosx_path

回答by Jay Sampat

environment.plstfile loads first on MAC so put the path on it.

environment.plst文件首先在 MAC 上加载,因此将路径放在其上。

For 1st time use, use the following command

第一次使用,使用以下命令

export PATH=$PATH: /path/to/set

回答by cody

use

利用

~/.bash_profile

or

或者

~/.MacOSX/environment.plist

(see Runtime Configuration Guidelines)

(请参阅运行时配置指南)