At the moment, when I open a terminal on my Mac, it automatically calls:
What bemuses me, however, is that my shell does not seem to inherit any of the content from
~/.profile. But that might be typical.
I have a number of scripts to inherit using
.; if I put those calls in
~/.bash_profile, it can take some time to load a new shell window, sometimes 3 or 4 seconds, and that gets old. I imagine that there is some way to source those scripts just once and have my
~/.bash_profile file inherit it somehow.
Note that calling source ~/.bashrc or source ~/.profile from my ~/.bash_profile is not what I want to do, and is also probably a bad idea. It's not what I want to do because it doesn't solve the problem of a slow load for each new shell.
I added some echo statements; every time I open a new bash terminal window, this is logged:
starting to load /etc/profile finished loading /etc/profile starting to load bash_profile finished loading bash_profile
that makes sense, but what is disheartening - do I really need to load these every time a new shell is opened? Why can't it do some fancy inheritance so that we don't have to reload everything every time?
I created a video demo'ing the problem. I have 4 terminal applications I use regularly:
terminal.app # misbehaves iterm2 # misbehaves webstorm terminal emulator # misbehaves vscode terminal emulator # behaves!
VSCode actually behaves in the way I would desire. I am guessing that it does this by loading ~/.bash_profile in a parent shell, and only doing that once, when vscode boots up. All of the terminal windows in the app, are then subshells of that one parent shell.
Hopefully this video makes the issue clear: https://www.useloom.com/share/4e62f0cb24434c4a83b8bd32844b596a
This is a legit issue - most terminal applications do this whole thing wrong, however, quite miraculously, it appears that VSCode from Microsoft actually does this whole thing the right way, see this issue: