oh-my-zsh themes don't show properly (background stays white) [closed]
Asked Answered
E

4

28

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.

Ezekielezell answered 27/12, 2012 at 14:10 Comment(2)
You have some colors (the ➜ ~ are red and aqua), but not all? Using your .zshrc and a fresh pull of oh-my-zsh with the Basic theme in Terminal.app, I have a white background / black text, red and aqua ~. Is this what you're expecting? It's not quite clear which colors you're not seeing correctly and which you are - a couple of screenshots might be helpful. :)Messere
@simont, in my .zshrc i clearly state "export ZSH_THEME="robbyrussell"" , shouldn't it look like the robbyrussell theme (with the black background and white text?"). Which lines are then responsible for the white background and black text if i just load the theme itself, and the theme looks different than that (i.e. black background and white text).Ezekielezell
M
42

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:

What you're seeing

and this is what you're expecting to see:

The RobbyRussell Theme

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:

Green background in the prompt

However, this more than likely is not what you want. Note several things:

  1. The bg[green] does not extend to the edge of the terminal window - the PROMPT settings only work where the line is drawn.
  2. The background color is reset to 'default' at the end of the prompt - that's done by %{$reset_color%} (necessary to change the foreground 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:

  1. The shell color settings. That's what you're doing in your zshrc. 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.
  2. 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 as red, $COLOR_2 as green", 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:

Robby Russel <code>zsh</code> theme with <code>Homebrew</code> Terminal.app profile

If you'd like a good, pre-set, easy-on-the-eyes color scheme, check out Solarized.

Messere answered 4/1, 2013 at 2:33 Comment(4)
A very thorough answer, thank you very much! I will try to implement it, but I guess the question that I have is: how come for me I need to set the colors, but colleague who sits next to me on exactly the same computer, has just set theme to robbyrussell and had no problems with the colors? As well as thousands of other users. This problem persists only for some users - those who found their way to the issue that I mentioned in the question.Ezekielezell
@Ezekielezell That's interesting. Using the same zsh settings as you, same terminal emulator, same OS?Messere
I have indeed ended up using Solarized; however the theme has to be chosen anew in the Settings every time I restart terminal app.Ezekielezell
@Ezekielezell - if you're using Terminal.app, you can set the default profile (select the profile, then press 'default'). I use iTerm2, which also lets you set the color scheme permanently.Messere
V
1

I was surprised this didn't work out of the box as well. However, I was able to get pretty close with just a few minor changes to the Basic theme:

enter image description here

  • Change the background to a dark color
  • Change text to a light color
  • Change selection/opacity to get a good highlight

Also, when selecting a color, use the eye dropper to get the exact color you're looking for:

enter image description here

With the eyedropper and a picture of his theme, you should be able to get pretty close.

Variolous answered 19/11, 2021 at 20:4 Comment(0)
S
0

Like said in the answer above it is "You need to change the terminal emulator color settings:"

I don't find any reason changing terminal app, the easiest way is only changing the theme to one of the available themes in the link below, you can find one that suits to oh-my-zsh themes.

osx-terminal-themes

Sidonia answered 1/1, 2018 at 10:12 Comment(0)
G
0

For me the fix was found in a preferences panel where I had to deselect which was overriding the theme...

I'm using gnome-terminal on an instance of Red Hat.

Found Under: Terminal -> Preferences -> Unnamed -> Colors -> Use colors from system theme

(took me much too long to realize that...)

Gibeonite answered 12/12, 2019 at 22:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.