我在我的中定义了三个别名.bash_profile
但我的 bash shell 没有读取它。定义的别名在我的终端中不起作用,我无法解决此问题。
alias handybook="cd /Users/rsukla/development/repos/handybook/"
该行定义在.bash_profile
但它在我的外壳中不起作用。
到目前为止我尝试过的事情:
知道为什么吗alias
当我定义时不工作.bash_profile
?
假设:
- 您使用 OS X 的本机终端 Terminal.app 或流行的替代方案iTerm2
- and
bash
确实是您的 shell(OS X 上的默认 shell)
then ~/.bash_profile
should为每个交互式 shell 加载, 因为两个终端程序都创建login默认为外壳.
Bash login贝壳来源~/.bash_profile
, 但不是~/.bashrc
.
Note that this differs from most Linux distros, where a single login shell is executed on startup, and later interactive shells are non-login shells, which only load ~/.bashrc
, not ~/.bash_profile
.
A frequently seen technique to ensure that definitions are loaded in both login and non-login interactive shells is to place definitions in ~/.bashrc
, and then source it from ~/.bash_profile
, using the following line:
[[ -f ~/.bashrc ]] && . ~/.bashrc
您可以通过执行按需创建登录 shellbash -l
来自现有的外壳;如果它加载了您的别名,那么问题一定出在您的默认 shell 是什么和/或您的终端程序是如何配置的。
-
echo $SHELL
告诉你你的默认 shell 是什么。
- 如果您使用 Terminal.app,
Terminal > Preferences...
, tab General
, 环境Shells open with
告诉您正在使用默认 shell 还是自定义 shell。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)