且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

.bashrc/.profile 没有加载到新的 tmux 会话(或窗口)上——为什么?

更新时间:2023-02-22 09:39:30

是的,在你的 .bash_profile 末尾,放一行:

.~/.bashrc

这会在通常只处理配置文件的情况下自动获取 rc 文件.

bash 何时运行某些文件的规则很复杂,取决于正在启动的 shell 的类型(登录/非登录、交互与否等),以及命令行参数和环境变量.

您可以在 man bash 输出中看到它们,只需查找 INVOCATION - 您可能需要一些时间来消化和解码它:-)>

When tmux starts or opens a new window, it does not load my .profile or .bashrc. I end up typing . ~/.bashrc every time. Is there a way to make this happen automatically?

Yes, at the end of your .bash_profile, put the line:

. ~/.bashrc

This automatically sources the rc file under those circumstances where it would normally only process the profile.

The rules as to when bash runs certain files are complicated, and depend on the type of shell being started (login/non-login, interactive or not, and so forth), along with command line arguments and environment variables.

You can see them in the man bash output, just look for INVOCATION - you'll probably need some time to digest and decode it though :-)