When tmux opens, I would like it to use zsh instead of bash by default. How would I accomplish this?
Asked
Active
Viewed 2.8k times
3 Answers
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"

d.danailov
- 9,594
- 4
- 51
- 36

jasonwryan
- 4,416
- 1
- 28
- 25
-
4remember to `killall tmux` after setting – northtree Jul 12 '17 at 05: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 – Mario Peshev Nov 15 '19 at 21:10
-
1my tmux would not change until I set the option from the command line: `tmux set-option -g default-shell /bin/zsh` – Richard Apr 15 '20 at 01: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.

Micah Elliott
- 9,600
- 5
- 51
- 54
-
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. ^_~ – Sardathrion - against SE abuse Jun 10 '15 at 09:25
-
-
another case is where chsh is broken, which is true on a particular (unnamed) university's CS servers – fouric Nov 08 '17 at 02: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

philipp2100
- 162
- 1
- 11