gpt4 book ai didi

macos - 每次打开终端时 Zsh 都显示失败

转载 作者:行者123 更新时间:2023-12-04 16:38:51 25 4
gpt4 key购买 nike

我正在使用装有 OS X Yosemite 和 Zsh 的 Mac。
我不小心删除了以下三个文件的内容:
.bashrc
.bash_profile
。轮廓
之后,当我打开终端时。
Zsh会在上次登录信息下显示失败,这让我很困惑,我想知道为什么。

最佳答案

Zsh(默认情况下)不会从 .bashrc.bash_profile.profile 读取,因此这些文件的内容应该无关紧要。您也没有提到哪些 .bashrc.bash_profile.profile 被删除了……这些文件存在于您的 /Users/username 目录和 /etc 中。启动时由 zsh 获取的文件列在“启动/关闭文件”下的 OS X zsh man page(终端中的 man zsh)中。它会调用前面提到的文件之一的唯一原因是如果它们在默认文件之一中明确为 source d。

我的建议:

  • 检查/etc/zshenv的内容(这是我etc目录中唯一的zsh特定文件)。我的只有以下几点:
    # system-wide environment settings for zsh(1)
    if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
    fi
  • 你能用zsh登录吗?如果没有,您可以使用另一个shell登录吗?您可以在 OS X Terminal.app 中执行此操作,方法是转到 Preferences -> General 并将“Shells open with:”选项从“Default login shell”更改为 Command(填写另一个 shell,即 /bin/bash/bin/sh )。如果您可以使用任何 shell 登录,请尝试以下解决方案 this question :

    Looking for the error

    All shell output goes to the terminal, so you could just redirect it when starting it. As you are looking for error messages during initialisation, I'd suggest the following procedure:

    1. Disable the problematic configurations
    2. Open a terminal
    3. Check the value of SHLVL: echo $SHLVL
    4. Re-enable the configurations
    5. Start a new z-shell from within the running shell with zsh 2> zsh-error.log, this redirects stderr to the file 'zsh-error.log'.
    6. Check the value of SHLVL again. If it is bigger then previous value then exit the current shell (exit). (Explanation below)
    7. Have a look at 'zsh-error.log' in the current directory.

    If 'zsh-error.log' does not show anything, you may want to run zsh -x
    2> zsh-error.log
    in step 5 instead. This provides a complete debug output of anything zsh does. This can get quite huge.



    正如答案所暗示的那样,如果您在启动时获取 man 文件,这些日志会变得非常庞大。只是一个裸 shell 应该会产生一个相当小的日志文件。
  • 最后,您可以通过运行 zsh -o sourcetrace 检索启动时由 zsh 获取的所有文件的列表。

  • 希望这可以帮助。

    关于macos - 每次打开终端时 Zsh 都显示失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29283187/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com