3

I've begun making my own oh-my-zsh theme, but I've run into a bit of a problem. I'm trying to change the color of the git output based on the name of the branch, and it works fine except for one important caveat: it changes the color to the correct one when zsh launches, but never re-evaluates what the color should be unless I re-launch zsh.

Here's a screenshot of the problem in action:

Screenshot of the problem

Here's a gist with my current zsh theme.

Am I doing something wrong, or does oh-my-zsh or zsh not support this kind of thing?

4

I haven't used oh-my-zsh (uh-oh) but I do use zsh and it and other shells do not reload configuration files between commands. You must explicitly reload them with the source command:

source ~/.zsh_config_file_you_modified_or_another_file

or

. ~/.zsh_config_file_you_modified_or_another_file

Starting a new zsh shell does that (completely with a new login shell, partially with a new sub shell as you did in the right pane above).

The complete list of which zsh config files are loaded on login vs normal shells is:

╔════════════════╦═══════════╦═══════════╦══════╗  
║                ║Interactive║Interactive║Script║  
║                ║login      ║non═login  ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║/etc/zshenv     ║    A      ║    A      ║  A   ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║~/.zshenv       ║    B      ║    B      ║  B   ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║/etc/zprofile   ║    C      ║           ║      ║   
╠════════════════╬═══════════╬═══════════╬══════╣   
║~/.zprofile     ║    D      ║           ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║/etc/zshrc      ║    E      ║    C      ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║~/.zshrc        ║    F      ║    D      ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║/etc/zlogin     ║    G      ║           ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║~/.zlogin       ║    H      ║           ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║                ║           ║           ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║                ║           ║           ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║~/.zlogout      ║    I      ║           ║      ║  
╠════════════════╬═══════════╬═══════════╬══════╣  
║/etc/zlogout    ║    J      ║           ║      ║  
╚════════════════╩═══════════╩═══════════╩══════╝  

If the files exist, they are loaded in A first, then B, C, D etc. I and J are only loaded/run on logging out / exiting a login shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.