Python 我在哪里可以找到 Mac 上的 bashrc 文件?

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

Where do I find the bashrc file on Mac?

pythonmacoshomebrew

提问by pencilVester

Hello I am following this page.. I'm installing Python onto my mac so that I can set up a Django / Eclipsedevelopment environment.
However I am not too sure how to go about executing this step:

您好,我正在关注此页面。我正在将 Python 安装到我的 mac 上,以便我可以设置Django / Eclipse开发环境。
但是,我不太确定如何执行此步骤:

  • The script will explain what changes it will make and prompt you before the installation begins.
  • Once you've installed Homebrew, insert the Homebrew directory at the top of your PATH environment variable.
  • You can do this by adding the following line at the bottom of your ~/.bashrc file

  • export PATH=/usr/local/bin:$PATH

  • 该脚本将解释它将进行哪些更改并在安装开始之前提示您。
  • 安装 Homebrew 后,在 PATH 环境变量的顶部插入 Homebrew 目录。
  • 您可以通过在~/.bashrc 文件底部添加以下行来完成此 操作

  • 导出路径=/usr/local/bin:$PATH

Where do I find the bashrc file on my mac and where do I find the homebrew directory?

我在哪里可以找到我的 mac 上的 bashrc 文件,我在哪里可以找到 homebrew 目录?

I am running a macbookpro with OS 10.8.5.

我正在macbook使用OS 10.8.5.

采纳答案by Peter Party Bus

The .bashrc file is in your home directory.

.bashrc 文件位于您的主目录中。

So from command line do:

所以从命令行做:

cd
ls -a

This will show all the hidden files in your home directory. "cd" will get you home and ls -a will "list all".

这将显示主目录中的所有隐藏文件。“cd”会让你回家,ls -a 会“列出所有”。

In general when you see ~/ the tilda slash refers to your home directory. So ~/.bashrc is your home directory with the .bashrc file.

通常,当您看到 ~/ 时,tilda 斜杠指的是您的主目录。所以 ~/.bashrc 是包含 .bashrc 文件的主目录。

And the standard path to homebrew is in /usr/local/ so if you:

自制软件的标准路径在 /usr/local/ 中,所以如果您:

cd /usr/local
ls | grep -i homebrew

you should see the homebrew directory (/usr/local/homebrew). Source

您应该会看到自制软件目录 (/usr/local/homebrew)。来源

Yes sometimes you may have to create this file and the typical format of a .bashrc file is:

是的,有时您可能需要创建此文件,.bashrc 文件的典型格式是:

# .bashrc

# User specific aliases and functions
. .alias
alias ducks='du -cks * | sort -rn | head -15'

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

PATH=$PATH:/home/username/bin:/usr/local/homebrew
export PATH

If you create your own .bashrc file make sure that the following line is in your ~/.bash_profile

如果您创建自己的 .bashrc 文件,请确保以下行在您的 ~/.bash_profile 中

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

回答by Kzhi

~/.bashrcis already a path to .bashrc.

~/.bashrc已经是.bashrc.

If you do echo ~you'll see that it's a path to your home directory.

如果你这样做,echo ~你会看到它是你的主目录的路径。

Homebrew directory is /usr/local/bin. Homebrew is installed inside it and everything installed by homebrew will be installed there.

Homebrew 目录是/usr/local/bin. Homebrew 安装在它里面,homebrew 安装的所有东西都将安装在那里。

For example, if you do brew install pythonHomebrew will put Python binary in /usr/local/bin.

例如,如果你做brew install pythonHomebrew 会将 Python 二进制文件放在/usr/local/bin.

Finally, to add Homebrew directory to your path you can run echo "export PATH=/usr/local/lib:$PATH" >> ~/.bashrc. It will create .bashrcfile if it doesn't exist and then append the needed line to the end.

最后,要将 Homebrew 目录添加到您的路径中,您可以运行echo "export PATH=/usr/local/lib:$PATH" >> ~/.bashrc. .bashrc如果文件不存在,它将创建文件,然后将所需的行附加到末尾。

You can check the result by running tail ~/.bashrc.

您可以通过运行来检查结果tail ~/.bashrc

回答by beroe

I would think you should add it to ~/.bash_profileinstead of .bashrc, (creating .bash_profileif it doesn't exist.) Then you don't have to add the extra step of checking for ~/.bashrcin your .bash_profile

我认为你应该将它添加到~/.bash_profile而不是.bashrc,(.bash_profile如果它不存在则创建。)然后你不必添加额外的步骤来检查~/.bashrc你的.bash_profile

Are you comfortable working and editing in a terminal? Just in case, ~/means your home directory, so if you open a new terminal window that is where you will be "located". And the dot at the front makes the file invisible to normal lscommand, unless you put -aor specify the file name.

您是否习惯在终端中工作和编辑?以防万一,这~/意味着您的主目录,因此如果您打开一个新的终端窗口,您将在该窗口“定位”。前面的点使文件对普通ls命令不可见,除非您输入-a或指定文件名。

Check this answerfor more detail.

检查此答案以获取更多详细信息。

回答by Balasubramani M

Open Terminal and execute commands given below.

打开终端并执行下面给出的命令。

cd /etc
subl bashrc

subl denotes Sublime editor. You can replace sublwith vito open bashrc file in default editor. This will workout only if you have bashrc file, created earlier.

subl 表示 Sublime 编辑器。您可以用vi替换subl以在默认编辑器中打开 bashrc 文件。只有当你有之前创建的 bashrc 文件时,这才会锻炼。

回答by Nioooooo

On some system, instead of the .bashrc file, you can edit your profils' specific by editing:

在某些系统上,您可以通过编辑而不是 .bashrc 文件来编辑特定于您的配置文件:

sudo nano /etc/profile

回答by samuel samer

On your Terminal:

在您的终端上:

  • Type cd ~/to go to your home folder.

  • Type touch .bash_profileto create your new file.

  • Edit .bash_profilewith your code editor (or you can just type open -e .bash_profileto open it in TextEdit).
  • Type . .bash_profileto reload .bash_profileand update any functions you add.
  • 键入cd ~/以转到您的主文件夹。

  • 键入touch .bash_profile以创建新文件。

  • 使用您的代码编辑器编辑.bash_profile(或者您可以直接open -e .bash_profile在 TextEdit 中输入 以打开它)。
  • 键入. .bash_profile以重新加载.bash_profile并更新您添加的任何功能。

回答by pensebien

The .bash_profile for most MAC Sierraare found in $HOME directory. You could create one if it does not exit. Sublime Text 3can help. If you follow the instruction from hereto launch ST3 with sublthen you can just do this

大多数MAC Sierra的 .bash_profile位于 $HOME 目录中。如果它不退出,您可以创建一个。Sublime Text 3可以帮助。如果您按照此处的说明进行操作,launch ST3 with subl则可以执行此操作

 $ subl ~/.bash_profile

Use Command + Shift + .to view hidden files in your HOME DIRECTORY

使用Command + Shift + .你的home目录查看隐藏文件