As many of you know, macOS is switching to zsh from bash. Before converting, I would like to play with zsh a bit.

Is there a way to open a single Terminal window or tab as a zsh shell, without having to set zsh as my default shell?

Can I, say, set up a profile in Terminal preferences with a Startup Run command that'll make windows/tabs opened with that profile run with a zsh shell?

I got something like what I want by creating a profile in Terminal preferences, clicking the Shell tab, clicking Run command, adding the command exec /bin/zsh, and clicking Run inside shell.

This does open a Terminal window running zsh - inside of bash. I'm looking, however, for a window opened running zsh on its own...

I want the shell to run the normal zsh startup/shutdown files - without having to change my default shell yet.

  • 2
    I don't get your point exactly. Why is exec zsh not sufficient to "play" a little bit? exec replaces the current shell with zsh, it's not run inside bash. Maybe you want to use exec zsh -l to get a socalled login shell, which sources different files; see INVOCATION in man zsh. – mpy Oct 8 '19 at 16:30
  • Yes, @mpy, I believe the "login shell" is what I am looking for. When I entered exec zsh -l, though, the window just crashed. Based on the man zsh page, I tried exec /bin/zsh -i("force shell to be interactive"), and the window opened. Now, I just need to test whether that runs the appropriate login and logout files (which is what I'm looking for)... – leanne Oct 9 '19 at 18:13

To launch an instance of the macOS Terminal App with a different shell you can launch a terminal with a different profile.
To do so, you need to export your settings profile from the preferences window, then open the settings file with the open command. For example:

open Documents/Profile.terminal

Related qestion

(As pointed out by @mpy) You can achieve something very similar by running exec zsh in bash.

Running exec zsh in bash replaces current process with zsh shell. You are not running zsh inside bash anymore, all the startup files were executed/sourced and all the shutdown files will run when the shell exits. This should be the exact experience you get when switching your default shell from bash to zsh.

It's not technically correct that all the startup and shutdown files will run when you exec zsh or when you launch a new terminal. This is because login and non-login shells have different startup/shutdown files they run/source. Some more information explaining login shells follows.

A login shell is the first process that executes under your user ID. When you launch a new terminal you always get a non-login interactive shell. Login shells are not usually interactive.

For more information about login and non-login shells see this question from unix stack exchange.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.