tmux 不使用默认 shell

Pet*_*ter 5 bash shell tmux

我的 tmux 开始出现短暂的奇怪行为。今天我注意到我的 tmux 会话不是以 bash shell 开头,而是以 ? 开头(不知道)。我看到的只是一美元$。然后如果我尝试调用 bashbash它会返回

sessions should be nested with care, unset $TMUX to force.
Run Code Online (Sandbox Code Playgroud)

没有 bash 的 tmux

我想在文件中添加default-shellfor tmux ~/.tmux.conf,但它不存在,如果我创建它,tmux 似乎看不到它。

Aul*_*nen 5

tmux 的手册页说明了 default-shell 选项过程:

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.

要在 .tmux.conf 文件中将 tmux 的默认 shell 设置为 Bash,必须将其编写为: set-option -g default-shell "/bin/bash"

如果您想将系统默认 shell(不是特定的 bash)设置为default-shell,您可以set-option -g default-shell $SHELL在 .tmux.conf 文件中执行此操作。但这需要$SHELL正确设置变量。请参阅https://superuser.com/a/395161/325399