【发布时间】:2021-08-03 21:55:04
【问题描述】:
在 macOS 下,在 .profile 中,我想为路径创建别名 myproj,例如 ~/Documents/mywork/project,以便在终端中我可以使用以下命令:
open myproj
我尝试简单地添加到 .profile 行...
alias myproj="~/Documents/mywork/project"
...但是在重新启动终端后,当我尝试open myproj 时出现错误:The file /Users/me/myproj does not exist.
怎么了?
【问题讨论】:
-
另外,如果你使用
bash,你会想要它在~/.bash_profile -
为什么是
~/.bash_profile而不是~/.profile?请注意,我在 macOS 下的 Terminal.app 的默认 shell 是zsh,不知何故我的~/.profile也会被读取(尽管我在~/.zshrc中没有明确加载它。 -
"如果你使用
bash..." - 这取决于你的shell。