Switching from zsh to bash on OS X, and back again?

BashTerminalZsh

Bash Problem Overview


I'm learning to develop in Rails, and have discovered the power of zsh. However, for some of my other tasks, I wish to use normal bash.

Although they are the same, I just feel comfortable with the layout of bash in some situations.

How do I switch back and forth, or turn zsh on and off?

Bash Solutions


Solution 1 - Bash

You can just use exec to replace your current shell with a new shell:

Switch to bash:

exec bash

Switch to zsh:

exec zsh

This won't affect new terminal windows or anything, but it's convenient.

Solution 2 - Bash

you can try chsh -s /bin/bash to set the bash as the default, or chsh -s /bin/zsh to set the zsh as the default.

Terminal will need a restart to take effect.

Solution 3 - Bash

I switch between zsh and bash somewhat frequently. For a while, I used to have to source my bash_profile every switch. Then I found out you can (typically) do

exec bash --login

or just

exec bash -l

Solution 4 - Bash

if it is just a temporary switch

you can use exec as mentioned above, but for more of a permanent solution.

you can use chsh -s /bin/bash (to switch to bash) and chsh -s /bin/zsh (to switch to zsh)

Solution 5 - Bash

For Bash, try

chsh -s $(which bash)

For zsh, try

chsh -s $(which zsh)

Solution 6 - Bash

zsh has a builtin command emulate which can emulate different shells by setting the appropriate options, although csh will never be fully emulated.

emulate bash
perform commands
emulate -R zsh

The -R flag restores all the options to their default values for that shell.

See: zsh manual

Solution 7 - Bash

In Mac OS Catalina default interactive shell is zsh. To change shell to zsh from bash:

chsh -s /bin/zsh

Then you need to enter your Mac password. Quit the terminal and reopen it. To check whether it's changed successfully to ssh, issue the following command.

echo $SHELL

If the result is /bin/zsh, your task is completed.

To change it back to bash, issue the following command on terminal.

chsh -s /bin/bash

Verify it again using echo $SHELL. Then result should be /bin/bash.

Solution 8 - Bash

you can just type bash or if you always want to use bash:

on "iTerm2"

  • Go to preferences > Profiles > Command
  • Select "Command" from the dropdown
  • Type bash

Test by closing iTerm and open it again

Solution 9 - Bash

You should be able just to type bash into the terminal to switch to bash, and then type zsh to switch to zsh. Works for me at least.

Solution 10 - Bash

Follow the below steps !

   chsh -s /bin/bash
   Restart terminal 
   check which shell is in use by echo $SHELL
   source .profile 

You are back with Bash !!

Solution 11 - Bash

You can easily switch back to bash by using command "bye"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionvpoola88View Question on Stackoverflow
Solution 1 - BashlarsksView Answer on Stackoverflow
Solution 2 - BashwanghaoView Answer on Stackoverflow
Solution 3 - Bashphil-ociraptorView Answer on Stackoverflow
Solution 4 - BashRahilView Answer on Stackoverflow
Solution 5 - Bashas - ifView Answer on Stackoverflow
Solution 6 - BashljcusackView Answer on Stackoverflow
Solution 7 - BashRandil TennakoonView Answer on Stackoverflow
Solution 8 - BashSarah AView Answer on Stackoverflow
Solution 9 - BashPaul JurczykView Answer on Stackoverflow
Solution 10 - Bashkushagra deepView Answer on Stackoverflow
Solution 11 - BashRajaniView Answer on Stackoverflow