How to use zsh and bash on iTerm2 at the same time

bashterminal

Zsh is better than bash(obviously), but for some reason, from time to time I have to use bash. I am wondering is there any way for me to use them together without changeing them manually?

What I have in mind is putting them in seperate tabs, I have tried it actually. Using zsh as default, and open another tab using different profile opening bash, though this can work, but all the configurations for bash didn't work.

So can anyone help me out here, thanks!

Best Answer

If by “all the configurations for bash didn’t work” you mean that customizations made in ~/.bash_profile (or ~/.profile or ~/.login) aren’t taking effect, that’s because bash is being invoked as a non-login shell (it runs ~/.bashrc instead).

To make it a login shell, the simplest solution is to add the -l option:

bash -l

Alternatively, if you want to actually create a login session you can invoke it via the login command. This creates a new login session (as displayed by the who command) and it invokes bash with the name -bash (as displayed by ps) to indicate it’s a login shell (same effect as the -l option):

login -f username bash