15

Right now I have my iTerm session configured to use zsh (/usr/local/bin/zsh), but I'm trying to configure tmux to use zsh as well, instead of /bin/bash/, which it's currently defaulting to. So far nothing I've read up on has gotten me where I need. Any ideas or things I may have missed?

Below are some details about my current setup. Thanks!

Check state:

1) Open iTerm

echo $SHELL

/bin/bash

ps -p $$

PID TTY TIME CMD 19626 ttys000 0:00.52 /usr/local/bin/zsh

2) Run tmux

tmux

echo $SHELL

/usr/local/bin/zsh

Configuration:

iTerm Profiles > General > Command:

/usr/local/bin/zsh

In .tmux.conf:

set-option -g default-shell /usr/local/bin/zsh

2
  • 2
    According to 2) tmux is using Zsh as your shell. What is your issue?
    – jasonwryan
    Jul 5, 2015 at 23:49
  • Sorry, I should have included that executing ps -p $$ in tmux prints: 20201 ttys001 0:00.02 -bash. Even though the $SHELL variable seems to be set, tmux doesn't actually seem to be using zsh. Also, on this machine powerline's only been configured for bash. Every time I start tmux, powerline's definitely visible. Jul 6, 2015 at 1:43

3 Answers 3

26

You need to set default-command:

set -g default-command /usr/local/bin/zsh

default-shell variable only use to create a login shell, when default-command is empty - which is default value.

Or you can simply change your default shell to zsh, in this case, tmux will start a login shell, instead of non-login shell.

4
  • 1
    This still doesn't seem to solve the issue. Jul 8, 2015 at 5:09
  • @JustianMeyer: Can you show me your .tmux.conf?
    – cuonglm
    Jul 8, 2015 at 5:12
  • 2
    @JustianMeyer Did you restart tmux with killall tmux; tmux command?
    – MOHRE
    Jul 18, 2017 at 6:46
  • One minor point, in this way, it start zsh as non-login shell, not login shell.
    – jdhao
    Jun 12, 2023 at 15:20
4

On top of what @cuonglm said, check for references to bash in your .tmux.conf.

For example, I was using a typical integration for copying & pasting in iTerm on Mac:

set-option -g default-command "reattach-to-user-namespace -l bash"

... which, to function properly with zsh had to be changed to:

set-option -g default-command "reattach-to-user-namespace -l zsh"

0

If you want to isolate this tmux setup from your regular, default one. One elegant solution is to use the combination of $SHELL and -L:

Set up an alias like so:

alias zshtmux='SHELL=/usr/local/bin/zsh tmux -L zsh'

This creates a seperate tmux instance named zsh. This instance will have default shell tempororily changed to /usr/local/bin/zsh, sepereate from the other tmux instances.

From here, you can work with this instance using zshtmux:

zshtmux new
zshtmux attach

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .