Zsh主题在OSX上无法正常工作

Kei*_*ith 3 macos zsh

刚刚开始使用zsh,但我在使主题工作方面遇到了很多麻烦.以下是我的ZSH提示中显示的内容:

$fg[cyan][$fg[white] keithy $fg[cyan]] [$fg[white]~/Desktop$fg[cyan]] >$reset_color
Run Code Online (Sandbox Code Playgroud)

我的〜/ .zshrc

source ~/.antigen.zsh

antigen theme jdavis/zsh-files themes/jdavis
Run Code Online (Sandbox Code Playgroud)

谢谢

4ae*_*1e1 6

TL; DR:.zshrc已在底部提供更正.您可能想先尝试一下,看看它是否正常工作,然后再回过头来阅读解释.


检查antigen.zshjdavis.zsh-theme,它看起来像你有两个问题:

  1. 您没有在任何地方加载和执行该colors功能.加

    autoload -U colors && colors
    
    Run Code Online (Sandbox Code Playgroud)

    到你的.zshrc.

  2. PROMPT是单引号而不是解析.您需要使用PROMPT_SUBST选项选项来解析提示字符串.加

    setopt promptsubst
    
    Run Code Online (Sandbox Code Playgroud)

    到你的.zshrc.根据链接的文档,该选项的作用如下:

    如果设置,则在提示中执行参数扩展,命令替换算术扩展.提示中的替换不会影响命令状态.

所以你.zshrc应该看起来像

source ~/.antigen.zsh
autoload -U colors && colors
setopt promptsubst
antigen theme jdavis/zsh-files themes/jdavis
Run Code Online (Sandbox Code Playgroud)