【问题标题】:.zshrc last line parse error near `\n' mac m1.zshrc `\\n\' mac m1 附近的最后一行解析错误
【发布时间】:2023-02-03 20:43:04
【问题描述】:

如题。看来我的.zshrc最后一行有问题。无论最后一行是什么,我都会收到 .zshrc:119: parse error near \n'` 错误。我正在使用 MAc M1 Max。用谷歌搜索了一些线程,但都没有用。

 Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
DEFAULT_USER="amber-moe"

if brew list | grep coreutils > /dev/null ; then PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH" alias ls='ls -F --show-control-chars --color=auto' eval `gdircolors -b $HOME/.dir_colors` fi


# The next line updates PATH for the Google Cloud SDK.
#if [ -f '/Users/xiaolang/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/xiaolang/google-cloud-sdk/path.zsh.inc'; fi

# The next line enables shell command completion for gcloud.
 if [ -f '/Users/xiaolang/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/xiaolang/google-cloud-sdk/completion.zsh.inc'; fi

这是我.zshrc的最后一行。谢谢你帮助我。

【问题讨论】:

    标签: zsh apple-m1


    【解决方案1】:

    您使用的是 MSDOS 结尾吗?好像这就是问题所在

    【讨论】:

      【解决方案2】:

      问题不在于最后一行;这是您的第一个 if 语句未正确终止,因此 zsh 仍在寻找 fi 但找到了 EOF。

      线

      if brew list | grep coreutils > /dev/null ; then PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH" alias ls='ls -F --show-control-chars --color=auto' eval `gdircolors -b $HOME/.dir_colors` fi
      

      实际上应该是几行:

      if brew list | grep coreutils > /dev/null ; then
        PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
        alias ls='ls -F --show-control-chars --color=auto' eval `gdircolors -b $HOME/.dir_colors`
      fi
      

      (您也可以在 aliasfi 之前添加分号,以达到相同的效果,而无需中断行。)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-11-05
        • 2022-07-06
        • 1970-01-01
        • 1970-01-01
        • 2018-10-19
        • 1970-01-01
        • 2021-10-26
        • 1970-01-01
        相关资源
        最近更新 更多