在 tmux 中时缺少 shopt -s autocd?

shopt -s autocd missing when inside tmux?

很奇怪。我在 .bashrc 文件中设置了 shopt -s autocd,如果我在 shell 中设置了 运行 shopt -p,我可以看到它可用(并已设置)。

但是当我启动 tmux shell 和 运行 shopt -p 时,autocd 选项不再显示,任何试图进入没有 [=16 的目录的尝试=] 命令前缀它会失败,并显示一条消息说 -bash: /Users/me/some/directory: is a directory

这是 shopt -p inside tmux...

的输出
shopt -u cdable_vars
shopt -s cdspell
shopt -u checkhash
shopt -s checkwinsize
shopt -s cmdhist
shopt -u compat31
shopt -s dotglob
shopt -u execfail
shopt -s expand_aliases
shopt -u extdebug
shopt -s extglob
shopt -s extquote
shopt -s failglob
shopt -s force_fignore
shopt -s gnu_errfmt
shopt -s histappend
shopt -u histreedit
shopt -u histverify
shopt -u hostcomplete
shopt -s huponexit
shopt -s interactive_comments
shopt -u lithist
shopt -s login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -s nocaseglob
shopt -u nocasematch
shopt -u nullglob
shopt -s progcomp
shopt -s promptvars
shopt -u restricted_shell
shopt -u shift_verbose
shopt -s sourcepath
shopt -u xpg_echo

这是 shopt -p outside tmux...

的输出
shopt -s autocd
shopt -u cdable_vars
shopt -s cdspell
shopt -u checkhash
shopt -u checkjobs
shopt -s checkwinsize
shopt -s cmdhist
shopt -u compat31
shopt -u compat32
shopt -u compat40
shopt -u compat41
shopt -u compat42
shopt -s complete_fullquote
shopt -u direxpand
shopt -s dirspell
shopt -s dotglob
shopt -u execfail
shopt -s expand_aliases
shopt -u extdebug
shopt -s extglob
shopt -s extquote
shopt -u failglob
shopt -s force_fignore
shopt -u globstar
shopt -u globasciiranges
shopt -s gnu_errfmt
shopt -s histappend
shopt -u histreedit
shopt -u histverify
shopt -u hostcomplete
shopt -s huponexit
shopt -s interactive_comments
shopt -u lastpipe
shopt -u lithist
shopt -s login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -s nocaseglob
shopt -u nocasematch
shopt -u nullglob
shopt -s progcomp
shopt -s promptvars
shopt -u restricted_shell
shopt -u shift_verbose
shopt -s sourcepath
shopt -u xpg_echo

tmux 默认为每个新 window/pane 创建一个登录名 shell。这意味着 .bash_profile(或者可能 .profile.bash_login,取决于可用文件)被执行,而不是 .bashrc。有关 default-shelldefault-conmand 选项的信息,请参阅手册页。

(报错信息中当前shell的名字,-bash,也确认你是在登录shell,不是常规的交互shell .)