Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Why isn't my zsh ls colorful?

Writer Sophia Terry

Spin up a new 16.04 server instance, install zsh, chsh to zsh, create the default .zshrc, log back in, ls output is not in colors. The .zshrc does seem to have all the proper dircolors and LS_COLORS stuff by the look of it, but then I'm not a zsh expert.

What am I missing?

2

2 Answers

ZSH outputs aren't colorful like bash outputs because the commands like ls,grep aren't colorful by default, bash has default aliases to make them colorful

To get the same colors in zsh as bash, add these lines to .zshrc Executegedit $HOME/.zshrc to open .zshrc (use your editor in place of gedit)

# enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' alias dir='dir --color=auto' alias vdir='vdir --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi
# some more ls aliases alias ll='ls -alF' alias la='ls -A' alias l='ls -CF'

(This is from .bashrc)

restart zsh and now the command outputs should be similar in bash

OK, so all I had to do was alias ls='ls --color'. Thanks to the folks in comments for pointing out that I'm being an idiot. :-)

(But why have I not had to do this before? I had always thought that ls by default is in color mode...)