现在,当我登录Tmux时,只会加载~/.bash_profile
。
我希望~/.bashrc
被调用。
这可能吗?
答案 0 :(得分:4)
此问题与tmux
无关。要解决此问题,请务必将source ~/.bashrc
添加到.bash_profile
以及它。
您可以详细了解bash
初始化及其加载的文件以及此处的顺序:https://github.com/sstephenson/rbenv/wiki/Unix-shell-initialization#bash
正如您所看到的,当bash以登录模式启动时,.bashrc
甚至不在列表中,这就是我们从列表中的文件(.bash_profile
)中获取它的原因
答案 1 :(得分:4)
您可以通过显式设置默认shell命令来修复tmux
级别:
tmux set-option default-command "/bin/bash"
从tmux
手册(强调我的):
default-command shell-command Set the command used for new windows (if not specified when the window is created) to shell-command, which may be any sh(1) command. The default is an empty string, which instructs tmux to create a **login shell** using the value of the default-shell option. default-shell path Specify the default shell. This is used as the login shell for new windows when the default-command option is set to empty, and must be the full path of the exe‐ cutable. When started tmux tries to set a default value from the first suitable of the SHELL environment vari‐ able, the shell returned by getpwuid(3), or /bin/sh. This option should be configured when tmux is used as a login shell.
如Chepner在下面的评论中解释的那样:
default-shell
默认为您首选的登录shell;default-command
默认有效地启动登录实例$SHELL -l
...对于Bash,登录 shell不会读取~/.bashrc
。通过覆盖default-command
的值,我们现在可以强制tmux
来创建非登录 shell。