如何创建 ~/.bash_profile 和 ~/.profile

[an error occurred while processing the directive]

你也可以使用图形用户界面的文本编辑器,比如TextEdit。

touch ~/.bash_profile

open -e ~/.bash_profile

open -e 是 open -a TextEdit 的快捷方式。

你不一定需要创建 .profile 或者 .bashrc 文件。Terminal 和 iTerm 2 打开新的 shell 时,会作为登录 shell 运行,所以 bash 不会读取 .bashrc 文件。如果同时存在 .bash_profile 和 .profile 文件,当以交互式登录 shell 方式调用 bash 时,只会读取 .bash_profile 文件。.profile 文件会在以交互式登录 shell 方式调用 ksh 时被读取,以及在以 sh 方式调用 bash 时作为交互式登录 shell 被读取。

我实际上已经告诉 iTerm 2 打开新的 shell 时作为非登录 shell 运行,并且我的 .bash_profile 文件只包含一行代码 . ~/.bashrc。tmux 和 emacs 中的 shell 模式默认打开新的 shell 时也作为非登录 shell 运行。当我通过 ssh 登录到我的计算机时,仍然会读取 .bash_profile 文件。

[an error occurred while processing the directive]

Copyright © 2088 星游活动站 - 新服开区专属福利 All Rights Reserved.
友情链接