Print View

Colors in ls
Updated: 07/14/2005


General Information

Ever wanted an easy way to distinguish directories and executables from everything else while you're ssh'ed in to your FreeBSD box?  You may have seen colors using ls on some Linux distros such as SlackWare but now you can have it on your FreeBSD machine.

Requirements

  1. Local root access on the box or be able to su to root.
  2. A SSH client that supports ANSI colors such as puTTy or SecureCRT.
  3. Your favorite text editor (I prefer nano).

Installation

Note:  This only works if your shell is bash.

Logon to the machine as root or su to root.
#
#
#
#
#
cd /usr/ports/misc/gnuls
make install
make clean
cd /etc
nano profile
Add the following:
alias ls="gnuls --color=always"
Log out and back in and enjoy.

Author: Kyle Symonds
ksymonds at gmail dot com



9 Comments

Posted by on August 28, 2005 at 5:40:01 pm PDT

You should probably modify ~/.profile as /etc/profile impacts all users. Also, no need to log out; just . or source ~/.profile


Posted by on August 28, 2005 at 5:40:01 pm PDT

I can't find the gnuls port.

#whereis gnlus
gnlus:
#


Posted by Jon on August 28, 2005 at 5:40:01 pm PDT

Try using gnuls instead of gnlus.  =)  The path is also mentioned in the above steps.


Posted by on August 28, 2005 at 5:40:01 pm PDT

You do know about 'ls -G', right? Stock FreeBSD command which will colorize its output in a color-enabled terminal. man ls(1).


Posted by weasel on August 28, 2005 at 5:40:01 pm PDT

Yes, but it doesn't look anywhere as pretty as gnuls does.  =)


Posted by alantam on August 28, 2005 at 5:40:01 pm PDT

If you use this in /etc/profile
alias ls='gnuls -hfAC --color=auto'

Then if you use putty or other clients, you will be able to see the colours as well.


Posted by vbrtrmn on August 28, 2005 at 5:40:01 pm PDT

OpenBSD 3.7
The executable has been renamed in gnuls-4.1p0.tgz
alias ls='gls --color=always'

I like:
alias ls='gls -lah --color=always'


Posted by nbritton on August 28, 2005 at 5:40:01 pm PDT

If you use csh or tcsh on FreeBSD you can put 'setenv CLICOLOR' in /etc/csh.cshrc or ~/.cshrc for color.

If you installed tcsh on a Linux system such as Redhat you can add something like this to the cshrc file:

alias ls        ls --color=auto
alias la        ls -a --color=auto
alias lf        ls -FA --color=auto
alias ll        ls -lAh --color=auto


Posted by matey on June 17, 2009 at 7:22:40 am PDT

Could /ports directory be under some other folders??

I cannot find it!
It is not under /usr and I do not know how to use the find command properly in OpenBSD!

I am used to Debian/Ubuntu kind of linux where you can do a find -name ports.
In BSD I used find -f / ports and it found every file and to control c out of it...

Any help would be appreciated.

Regards;
med


Copyright 2003 - 2012 BSD Guides.  All rights reserved.

About | Terms of Use | Privacy | Contact