哦-my-zsh主题没有正确显示(背景保持白色)

zim*_*ima 18 zsh zshrc osx-lion

我想弄清楚为什么我的oh-my-zsh主题不能正常工作.颜色正确显示,但背景保持白色(黑色文字).下面是我的/.zshrc文件和当前路径变量:

    # Path to your oh-my-zsh configuration.
    ZSH=$HOME/.oh-my-zsh

    export PATH="$HOME/.rbenv/bin:$PATH"
    eval "$(rbenv init -)"

    # Set name of the theme to load.
    # Look in ~/.oh-my-zsh/themes/
    # Optionally, if you set this to "random", it'll load a random theme each
    # time that oh-my-zsh is loaded.
    export ZSH_THEME="robbyrussell"

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

    # Set to this to use case-sensitive completion
    # CASE_SENSITIVE="true"

    # Comment this out to disable weekly auto-update checks
    # DISABLE_AUTO_UPDATE="true"

    # Uncomment following line if you want to disable colors in ls
    #DISABLE_LS_COLORS="true"

    # Uncomment following line if you want to disable autosetting terminal title.
    # DISABLE_AUTO_TITLE="true"

    # Uncomment following line if you want red dots to be displayed while waiting for   completion
    # COMPLETION_WAITING_DOTS="true"

    # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
    # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
    # Example format: plugins=(rails git textmate ruby lighthouse)
    plugins=(git rails ruby brew)

    source $ZSH/oh-my-zsh.sh

    # Customize to your needs...
    autoload -U colors
    colors
Run Code Online (Sandbox Code Playgroud)

这是$ PATH:

    ?  ~  echo $PATH
    /Users/natascha/.rbenv/shims:/Users/natascha/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/texbin
Run Code Online (Sandbox Code Playgroud)

我在Mac OS X 10.7.5上并在几个月前安装了oh-my-zsh ..我在git问题上发了帖子,https://github.com/robbyrussell/oh-my-zsh/issues/929# issuecomment-11652602,似乎还没有解决?我的插件工作(即我可以键入rails c for"rails console").

感谢您的任何帮助.

sim*_*ont 27

简答:不,zsh不能帮到你.您需要更改终端仿真器颜色设置,而不是zsh设置.

这是你目前看到的:

你看到了什么

这就是你期望看到的:

RobbyRussell主题

这是产生此提示的行:

PROMPT='%{$fg_bold[red]%}? %{$fg_bold[green]%}%p %{$fg[cyan]%}%c 
%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
Run Code Online (Sandbox Code Playgroud)

在Z-壳牌确实有一些foreground,background你可以在使用的设置PROMPT-这是什么fg_bold手段(前台加粗).您可以将其替换bg_为背景,并省略bold使用非粗体字体.

例如,我们可以通过添加以下内容来设置PROMPTto 的背景:green%{bg[green]%}

PROMPT='%{$bg[green]%}%{$fg_bold[red]%}? %{$fg_bold[green]%}%p %{$fg[cyan]%}%c 
%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
Run Code Online (Sandbox Code Playgroud)

这导致:

提示中的绿色背景

但是,这很可能不是你想要的.注意几件事:

  1. bg[green]延伸到终端窗口的边缘-在PROMPT设置其中线被绘制只工作.
  2. 在提示结束时将背景颜色重置为"默认" - 这是由%{$reset_color%}(将foreground颜色更改为默认值所必需的)完成的.获得一致的全线背景颜色会很快变得混乱.

颜色如何工作

大致(我可能在细节上有误,但总体要点是正确的,我相信):你使用的shell发送color code终端模拟器.的终端仿真器是负责解释该颜色代码,并在屏幕上显示它.这意味着您可以使用两种设置:

  1. shell颜色设置.这就是你在做什么zshrc.Primiarily,这允许一致性-你可以说"显示提示的位在同一$COLOR作为提示的位".这并不意味着用户会看到提示$COLOR; $COLOR是一个标签,而不是更多.
  2. 显示颜色设置.这就是你设置的首选font,background,text color,等,这是在那里你可以说"显示一切壳说是$COLOR_1因为red,$COLOR_2作为green"等.

您可以在ANSI终端中使用16种颜色,这些颜色可能或可能无法正确显示.检查此表中的常见端子颜色,并注意它们之间显示的差异!

修复你的颜色

如果您正在使用Terminal.app(在OS X上,我建议iTerm2),打开终端(command+ ,)的首选项,然后选择"设置".你可以选择一些"配置文件" - 模仿robbyrussell上面的截图,你想要稍微调整一下颜色."Homebrew"非常接近,但有不同的"文字"颜色(绿色而不是白色).

[这是Terminal.app配置文件的robbyrussell zsh主题Homebrew:

Robby Russel <code> zsh </ code>主题与<code> Homebrew </ code> Terminal.app个人资料

如果你想要一个好的,预设的,易于上手的配色方案,请查看Solarized.