使用`zsh-newuser-install:启动文件存在,正在中止`在tmux内部启动时zsh崩溃

Ric*_*d87 11 linux zsh tmux

每次我尝试zshtmux它内部启动时都会崩溃 wwith

zsh-newuser-install:  startup files exist, aborting
Run Code Online (Sandbox Code Playgroud)

昨天晚上它完美无缺,今天早上突然没有任何效果......

我用这一行作为第一个开始 tmux .zshrc

if [ "$TMUX" = "" ]; then tmux; fi
Run Code Online (Sandbox Code Playgroud)

谢谢!

我的zshrc文件:https : //github.com/Richard87/oh-my-zsh/blob/master/templates/zshrc.zsh-template

编辑

它突然又开始工作了......我不知道发生了什么变化,或者出了什么问题......从头开始,它再次停止工作

编辑#2

在同一台计算机上,它适用于 root 用户,但不适用于我的主用户(.zshrc 文件完全相同,唯一不同的是我自己的用户有一个自定义的 tmux 配置文件:

# set Zsh as your default Tmux shell
set-option -g default-shell /bin/zsh

# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"


# Tmux uses a 'control key', let's set it to 'Ctrl-a'
# Reason: 'Ctrl-a' is easier to reach than 'Ctrl-b'
set -g prefix C-a
unbind C-b

# command delay? We don't want that, make it short
set -sg escape-time 1

# Set the numbering of windows to go from 1 instead
# of 0 - silly programmers :|
set-option -g base-index 1
setw -g pane-base-index 1


# Allow us to reload our Tmux configuration while
# using Tmux
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# Getting interesting now, we use the vertical and horizontal
# symbols to split the screen
bind | split-window -h
bind - split-window -v
Run Code Online (Sandbox Code Playgroud)

DWi*_*hes 11

启动后,当我在打开独立终端之前在 IntelliJ 中打开终端时,就会发生这种情况:

  • 如果我先打开独立终端,独立终端和 IntelliJ 的终端都可以正常工作。
  • 如果我先打开 IntelliJ 的终端,独立和 IntelliJ 的终端都无法显示以下消息:zsh-newuser-install: startup files exist, aborting.

我发现的唯一解决方法是:

  1. 关闭所有终端并打开一个独立终端,不应显示该消息,然后打开此终端时,打开 IntelliJ 终端,问题将不再发生。
  2. 在某些情况下这不起作用,因为我先打开了独立终端。在这种情况下,我会按照@rghamilton3 的建议进行操作:tmux kill-server然后再次执行 #1。


小智 5

我知道这是旧的,但我看到了更新的评论,我刚刚发生了这种情况。我只是通过运行杀死了服务器tmux kill-server,令人惊讶的是它确实为我修复了它。YMMV 当然,但希望它可以帮助其他人。


小智 1

首先,只有在以下情况下才应运行zsh-newuser-install 函数:

1)用户没有任何个人zsh启动文件(如.zshrc)

2) 如果您的 .zshrc 文件中出现以下行:

autoload -Uz zsh-newuser-install
zsh-newuser-install -f
Run Code Online (Sandbox Code Playgroud)

3) 如果手动运行相同的命令。

我会检查您的 .zshrc 文件以防万一。希望这会给您一个开始寻找的地方。

就我个人而言,我不会将 tmux 命令放在 .zshrc 文件的第一行,但这是我个人的意见。我相信使用TMUX变量并不是确定 tmux 是否已经运行的最佳选择。您必须启动在 tmux 窗口/窗格中运行的 shell 才能TMUX设置变量。tmux ls在我看来,结果将是一个更好的选择。

Var=("${(f)$(tmux ls)}")
[ ${#Var} -eq 0 ] && tmux
Run Code Online (Sandbox Code Playgroud)

由于我不知道你的用例,你可能不会选择这种方法。