Thursday, May 21, 2015

MAC to Linux dircolors does not work

Going from MAC to Linux over ssh the dircolors command does not work

When you test dircolors command with simply typing dircolors it gives:
$ dircolors
LS_COLORS='';
export LS_COLORS

The cause is that the discolors is inspecting the TERM variable and the TERM as reported is:

$ echo $TERM
xterm-256color

The fix to get around this is to add the line into the .dir_colors for this terminal type
TERM xterm
TERM xterm-256color
TERM xterm-color
TERM xterm-debian
TERM rxvt

Notes: 

  • The $HOME/.dir_colors can be your custom color setup. 
  • You can typically get a vanilla copy from /etc/dircolors
  • If not, you can run the following command to print the database of dircolors into this file.
    dircolors -p > ~/.dir_colors
  • Next, add the following into your .profile, .bash_profile etc. wherever appropriate.
    eval `dircolors -b ~/.dir_colors`
    alias ls='ls --color=always'
Now, 'ls' command will appropriately color the entries and it will work when ssh'ing from a mac.

No comments:

Post a Comment