7 bash osx-snow-leopard .bash-profile macos
我如何编辑bash_profile
?我试过使用该命令,chflags
但它显示错误
[写错了。Bash_profile:不允许操作]
我使用的是 OS X Snow Leopard 10.6.8。
slh*_*hck 12
在大多数情况下,该文件甚至不存在,除非您专门创建它。为了做到这一点,你不需要chflags
. 事实上,如果您是一个典型的用户,那么chflags
您的 Mac根本不需要。
只需输入:
cd
touch .bash_profile
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用您喜欢的任何应用程序对其进行编辑,例如基于终端的编辑器,例如vim
、nano
甚至 TextEdit:
vim .bash_profile
nano .bash_profile
open -a "TextEdit" .bash_profile
Run Code Online (Sandbox Code Playgroud)
编辑完文件后,请确保.bash_profile
再次获取源文件。否则,bash 将无法识别更改:
source .bash_profile
Run Code Online (Sandbox Code Playgroud)
如果由于某种原因您没有权限,请确保在.bash_profile
使用ls -la
- 即模式 644,由您拥有的目录列表时您看起来像这样。
charon:~ werner$ ls -l .bash_profile
-rw-r--r-- 1 werner staff 1323 Apr 4 18:00 .bash_profile
Run Code Online (Sandbox Code Playgroud)