# Remove color from 'ls' output



## drhowarddrfine (Jan 18, 2019)

Something updated when I either went to 12.0 or some other update but I don't remember, and can't find how, to have a monochrome, white on black, output from `ls` while in `sh` on x11-wm/i3. When I'm root, it works as desired. It's only when I'm logged in as a user.

I haven't touched this in years so I can't figure out how to revert back.


----------



## VladiBG (Jan 18, 2019)

I don't use Xorg but for the console it's env variable called CLICOLOR and COLORTERM for terminals.

for example in csh you can do this

#this will disable console colors
`unsetenv CLICOLOR`
or
#check and modify the alias if any in .cshrc for ls command to enable/disable colorized output
`alias ls ls -G`
where -G enables the colorized output

for virtual terminals check the options in the terminal itself.

#edit
you can check ~/.profile file for the user and there to remove the CLICOLOR env


----------



## drhowarddrfine (Jan 18, 2019)

I've done all those things to no avail. I am wondering if it's a setting in i3 but I don't see anything and, as I said, in root ls doesn't display color.

I did put `alias ls ls --color=none` in root's .cshrc file and removing that introduces color in ls for root. I created a .shrc file for me as user but that won't work there.


----------



## drhowarddrfine (Jan 18, 2019)

I might be onto something. I'm using urxvt and I'm betting I need to look into the configuration there. I did look there but didn't immediately see anything but I have a hunch therein lies the problem.


----------



## Spartrekus (Jan 18, 2019)

maybe in c:


```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>   //chdir
#include <dirent.h>

int main( int argc, char *argv[])
{
    if ( argc >= 2)
      if ( strcmp( argv[1] , "" ) !=  0 )
     chdir( argv[ 1 ] );

   DIR *dirp;
   struct dirent *dp;
   dirp = opendir( "." );
   while  ((dp = readdir( dirp )) != NULL )
   {
         if (  strcmp( dp->d_name, "." ) != 0 )
         if (  strcmp( dp->d_name, ".." ) != 0 )
             printf( "%s\n", dp->d_name );
   }
   closedir( dirp );
   return 0;
}
```

clang ls.c -o ls ; ./ls


----------



## SirDice (Jan 18, 2019)

drhowarddrfine said:


> I'm using urxvt and I'm betting I need to look into the configuration there. I did look there but didn't immediately see anything but I have a hunch therein lies the problem.


For sh(1) make sure to check files like ~/.profile and /etc/profile. For xterm/urxvt you may have some settings in ~/.Xdefaults or ~/.Xresources.


----------



## drhowarddrfine (Jan 18, 2019)

Done that. It seems like I used to have a .urxvt file and no longer do. There are settings in .Xdefaults but the same as always and I specify foregroud and background which is probably why everything else is mono.

Something has changed somewhere and I thought I read on the mailing list that it had to do with `ls`


----------



## phoenix (Jan 18, 2019)

drhowarddrfine said:


> I've done all those things to no avail. I am wondering if it's a setting in i3 but I don't see anything and, as I said, in root ls doesn't display color.
> 
> I did put `alias ls ls --color=none` in root's .cshrc file and removing that introduces color in ls for root. I created a .shrc file for me as user but that won't work there.



FreeBSD ls(1) doesn't support long options.  The fact you use *--color=none* to remove the colouring means you've installed misc/gnuls and configured your user to use that (whether via alias or putting /usr/local/bin ahead of /bin in your *PATH*).

What happens if you execute /bin/ls directly?  Bet it's black and white.  

Edit:  nevermind, it seems the FreeBSD version of ls in 12.0 now support *--color=* option.  It's not available on my 10.x systems, which is where I'm reading man pages from.


----------



## drhowarddrfine (Jan 18, 2019)

phoenix Then I guess that confirms what I just said about reading something about `ls`. I just need to know where I can put the color option to make this permanent.


----------

