Note: Obviously something wrong has happened with the previous and orignal thread, the gdircolors output when pasted did not automatically wrap with this page and it made the page wider than the screen as it can be. So I made the corrections and here it is again and made comfortable to read. Hope this is okay with the moderators and LQ - a repeated thread.
Linux consoles are colorized by default, but with OpenBSD, there are still efforts that need to be done but it is not that hard as you may think.
Linux uses the GNU Fileutils that has the ls, touch, df, dir, vdir, etc. The binary that is included here that paints the console is
"dircolors". And fortunately, there is an available port for these utilities in OpenBSD that will make our installations easier and we don't have to do it direct from source plus with all the patches applied as well for us. Though when I tried, it worked as well.
Installations:
Code:
# cd /usr/ports/misc/fileutils
# make && make install
That's all. But make sure that you updated first your ports tree before doing this not unless you have just done it lately. For the benefit of all of us, here is how to update your ports:
Using bash/ksh shell:
Code:
# export CVSROOT=anoncvs@anoncvs.somewhere.openbsd.org:/cvs
# cd /usr
# cvs up -rOPENBSD_3_x -Pd ports
Using csh shell:
Code:
# setenv CVSROOT=anoncvs@anoncvs.somewhere.openbsd.org:/cvs
# cd /usr
# cvs up -rOPENBSD_3_x -Pd ports
The utilities are renamed to gls, gtouch, gvdir, gdir, etc and are installed in /usr/local/bin so that they will not override OBSD's default file utils which are in /bin and /usr/bin.
Testing the installations and colors:
Verify if the files are in /usr/local/bin by going there and inspecting them through ls or using whereis command.
Here I've tested this using ksh shell.
Logon now as ordinary user and make sure that your logon shell is /bin/ksh by editing the password database using vipw as root.
urusername:$2a$06$lhskRKa*C:1000:1000::0:0:MyUsername:/home/urusername:
/bin/ksh
$ gdircolors
LS_COLORS='no=00:fi=00:di=01;34:ln=01;36
i=40;33:so=01;35:do=01;35:bd=40;33;01
:cd=40;33;01
r=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31
:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:
*.rpm=01;31:*.jpg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35
:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.png=01;35:*.mpg=01;35:*.avi=01;35:*.fli=01;35
:*.gl=01;35:*.dl=01;35:';
export LS_COLORS
To see what are these numbers' color equivalents:
$ gdircolors -p |less or pipe it to a file for you to read ($ gdircolors -p > ~/dir_colors) using less and vi.
Now let us test if the colors are already there to serve us.
Code:
$ eval `gdircolors -b`
$ gls --color
$ alias ls='gls --color -F'
It is single quotes that enclosed alias values.
The -b option is for bash and ksh shells.
You should see real colors now!
Let us add another alias:
Code:
$ alias dir='gdir --color'
$ dir
Put it now in your ~/.profile ( or /home/.profile):
To see colors on our consoles always, edit now your .profile to add these lines.
Code:
# LS Colors
eval `/usr/local/bin/gdircolors -b`
alias dir='/usr/local/bin/gdir --color'
alias vdir='/usr/local/bin/gvdir --color'
alias ls='/usr/local/bin/gls --color -F'
alias ll='/usr/local/bin/gls --color -l -F'
Logout and logon again and test all the aliases we made - dir, vdir, ls & ll.
Do as well with root and other users and of course since this is a logon script, after an su to root, the colors will be gone. Just make an alias to ls such as:
Code:
# alias ls='gls --color -F'
Hope this helps. Have colorful days! I'm experiencing colors both when logon directly to the box or remotely via Windows PUTTY.
I'm using OpenBSD 3.6.