Automatically colorize the output of tree

colorstreezsh

In plain zsh, tree is set similar to --color=auto by default. However, when I use Oh-My-Zsh, tree doesn't show colors. Since tree does not have a --color=auto option, how can I override the setting back to the auto one?

Best Answer

I found the answer after I posted an issue on Oh-My-Zsh's repository. Color in tree rely on LS_COLORS, which is not set by Zsh by default; but my ~/.zshrc set the variable after I hit "use default setting" option, with a single line

eval "$(dircolors -b)"

which looks insignificant. After installing Oh-My-Zsh, the setting is moved to ~/.zshrc.pre-oh-my-zsh, so LS_COLORS is lost again, and my tree becomes black and white.

In other words, I moved that setting from ~/.zshrc.pre-oh-my-zsh back to .zshrc, and I am now with my colorful tree.