38

When tmux opens, I would like it to use zsh instead of bash by default. How would I accomplish this?

3 Answers 3

61

From man tmux:

default-shell path
Specify the default shell. This is used as the login shell for new windows when the default-command option is set to empty, and must be the full path of the executable. When started tmux tries to set a default value from the first suitable of the SHELL environment variable, the shell returned by getpwuid(3), or /bin/sh. This option should be configured when tmux is used as a login shell.

So, in your tmux.conf:

# set shell
set -g default-shell /bin/zsh

and if you want you can add default command each time, when we start a new window:

# Retach userspaces
set -g default-command "reattach-to-user-namespace -l zsh"
3
  • 4
    remember to killall tmux after setting
    – northtree
    Commented Jul 12, 2017 at 5:26
  • 1
    killall tmux doesn't work here for some reason. I had to top and kill all processes individually to reload the config once again Commented Nov 15, 2019 at 21:10
  • 1
    my tmux would not change until I set the option from the command line: tmux set-option -g default-shell /bin/zsh
    – Richard
    Commented Apr 15, 2020 at 1:19
8

You probably want zsh to be your default shell for most things, then (but this will not apply to cron). The following will make zsh your default shell, and you should then not need to tell tmux anything.

chsh -s /usr/bin/zsh

Note that some OSs still use /bin/zsh as the path to zsh.

3
  • Here's a use case where this is not true: There's a "build" account that is used by multiple people and some of them cannot be bothered to use tmux/zsh all the time. ^_~ Commented Jun 10, 2015 at 9:25
  • another case is when using tmux itself as default shell Commented Oct 19, 2016 at 6:44
  • another case is where chsh is broken, which is true on a particular (unnamed) university's CS servers
    – fouric
    Commented Nov 8, 2017 at 2:05
0

If you prefer to set it individually for a session, but not for other (future) sessions, you can use

 tmux new-session /bin/zsh \; set default-shell /bin/zsh

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