Why isn't my zsh ls colorful?

9,102

Solution 1

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 Execute gedit $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

Solution 2

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...)

Share:
9,102

Related videos on Youtube

jingx
Author by

jingx

Updated on September 18, 2022

Comments

  • jingx
    jingx almost 2 years

    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?