oh-my-zsh 主题显示不正确(背景保持白色) [英] oh-my-zsh themes don't show properly (background stays white)
问题描述
我想弄清楚为什么我的 oh-my-zsh 主题无法正常工作.颜色显示正确,但背景保持白色(带有黑色文本).下面是我的/.zshrc 文件和当前路径变量:
# oh-my-zsh 配置的路径.ZSH=$HOME/.oh-my-zsh导出路径="$HOME/.rbenv/bin:$PATH"eval "$(rbenv init -)"# 设置要加载的主题名称.# 查看 ~/.oh-my-zsh/themes/# 可选地,如果您将其设置为随机",它将加载一个随机主题# oh-my-zsh 加载的时间.出口 ZSH_THEME="robbyrussell"# 示例别名# 别名 zshconfig="mate ~/.zshrc"# 别名 ohmyzsh="mate ~/.oh-my-zsh"# 设置为这个以使用区分大小写的完成# CASE_SENSITIVE="true"# 注释掉以禁用每周自动更新检查# DISABLE_AUTO_UPDATE="真"# 如果要在 ls 中禁用颜色,请取消注释以下行#DISABLE_LS_COLORS="真"# 如果要禁用自动设置终端标题,请取消注释以下行.# DISABLE_AUTO_TITLE="true"# 如果您希望在等待完成时显示红点,请取消注释以下行# COMPLETION_WAITING_DOTS="true"# 你想加载哪些插件?(插件可以在 ~/.oh-my-zsh/plugins/* 中找到)# 自定义插件可以添加到 ~/.oh-my-zsh/custom/plugins/# 示例格式:plugins=(rails git textmate ruby lighthouse)插件=(git rails ruby brew)来源 $ZSH/oh-my-zsh.sh# 根据您的需要定制...自动加载 -U 颜色颜色
这里是 $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
我在 Mac OS X 10.7.5 上安装了 oh-my-zsh 几个月前..我在 git issue 中发了一个帖子,以了解一些常见的终端颜色,并注意它们之间显示的差异!
调整颜色
如果您使用 Terminal.app
(在 OS X 上,我建议使用 iTerm2
),打开终端的首选项(command+,),然后选择设置".您可以从一堆配置文件"中进行选择 - 要模拟上面的 robbyrussell
屏幕截图,您需要稍微调整一下颜色.Homebrew"非常接近,但具有不同的文本"颜色(绿色而不是白色).
[这是带有 Homebrew
Terminal.app 配置文件的 robbyrussell
zsh
主题:
如果您想要一个好的、预先设定的、赏心悦目的配色方案,请查看 Solarized.
I am trying to figure out why my oh-my-zsh themes don't work properly. The colors show up properly, but background stays white (with black text). below is my /.zshrc file and current path variable:
# 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
here is $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
I am on Mac OS X 10.7.5 and installed oh-my-zsh months ago.. I have made a post in the git issue, https://github.com/robbyrussell/oh-my-zsh/issues/929#issuecomment-11652602, it seems to still have not been resolved? My plugins work ( i.e. i can type rails c for "rails console").
Thank you for any help.
Short answer: no, zsh
can't help you here. You need to change the terminal emulator color settings, not the zsh
settings.
This is what you're currently seeing:
and this is what you're expecting to see:
This is the line that produces this prompt:
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c
%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
The Z-Shell does have some foreground
, background
settings you can use in the PROMPT
- that's what the fg_bold
means (foreground to bold). You can replace this with bg_
for background, and omit the bold
to use a non-bold font.
For example, we can set the background of the PROMPT
to green
by adding %{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%}'
This results in:
However, this more than likely is not what you want. Note several things:
- The
bg[green]
does not extend to the edge of the terminal window - thePROMPT
settings only work where the line is drawn. - The background color is reset to 'default' at the end of the prompt - that's done by
%{$reset_color%}
(necessary to change theforeground
color to default). Getting a consistant, whole-line background color gets messy quickly.
How the colors work
Roughly (I could be wrong in details, but the overall gist is correct, I believe): the shell you use sends a color code
to the terminal emulator. The terminal emulator is responsible for interpreting that color code, and displaying it on the screen. This means there are two settings you can fiddle with:
- The
shell
color settings. That's what you're doing in yourzshrc
. Primiarily, this allows for consistency - you can say "Display this bit of the prompt in the same$COLOR
as that bit of the prompt". This doesn't mean the user will see the prompt in$COLOR
;$COLOR
is a label, not much more. - The displayed color settings. That's where you set the preferred
font
,background
,text color
, etc. It's where you can say "display everything the shell says is$COLOR_1
asred
,$COLOR_2
asgreen
", etc.
There are 16 colors you can use in an ANSI
terminal, which may-or-may-not be displayed correctly. Check this table for some common terminal colors, and note the differences displayed between them!
Fixing your colors
If you're using Terminal.app
(on OS X, I'd recommend iTerm2
), open the preferences for Terminal (command+,), and select "Settings". There's a bunch of "profiles" you can choose from - to emulate the robbyrussell
screenshot above, you'd want to fiddle with the colors a little. "Homebrew" is pretty close, but has different "text" colors (green instead of white).
[Here is the robbyrussell
zsh
theme with the Homebrew
Terminal.app profile:
If you'd like a good, pre-set, easy-on-the-eyes color scheme, check out Solarized.
这篇关于oh-my-zsh 主题显示不正确(背景保持白色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!