use*_*043 5 macos shell command
我.bashrc在Mac OS上有一个文件,我在其中设置了一些别名.在我制作并输入之后source .bashrc,别名可以完美地工作.但是,如果打开另一个shell,我的快捷命令将无法识别,我需要source .bashrc再次执行.怎么能一劳永逸呢?
终端和iTerm 2默认打开新shell作为登录shell.当Bash作为登录shell打开时,它会读取~/.bash_profile但不会~/.bashrc.
请参阅https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html:
作为交互式登录shell调用,或使用--login调用
当Bash作为交互式登录shell或具有--login选项的非交互式shell调用时,它首先从文件/ etc/profile中读取并执行命令(如果该文件存在).在读取该文件之后,它按顺序查找〜/ .bash_profile,〜/ .bash_login和〜/ .profile,并从存在且可读的第一个命令中读取并执行命令.启动shell以禁止此行为时,可以使用--noprofile选项.
所以要么:
~/.bash_profile而不是~/.bashrc.~/.bashrc但~/.bashrc源自~/.bash_profile.我做了最后两个.例如tmux,Emacs中的shell模式将新shell打开为非登录shell.我仍然来源~/.bashrc,~/.bash_profile因为当我ssh到我的电脑时,Bash作为登录shell打开.
如果您使用的是 Mac 并且您希望在打开source ~/.bash_profilea 时自动打开terminal
| 归档时间: |
|
| 查看次数: |
30072 次 |
| 最近记录: |