LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 09-13-2005, 06:52 AM   #1
gani
Member
 
Registered: Jun 2004
Location: Metro Manila, Philippines
Distribution: Linuxmint, Slackware
Posts: 356

Rep: Reputation: 34
Colorizing OpenBSD Text Console


Linux consoles are colorized by default, but with OpenBSD, there are still efforts that need 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 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. 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;36i=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01r=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=0 1;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:*.fl i=01;35:*.gl=01;35:*.dl=01;35:';
export LS_COLORS

To see what are these numbers’ equivalent colors:

$ 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'
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.
 
Old 09-13-2005, 08:27 AM   #2
gani
Member
 
Registered: Jun 2004
Location: Metro Manila, Philippines
Distribution: Linuxmint, Slackware
Posts: 356

Original Poster
Rep: Reputation: 34
Re posted: Colorizing OpenBSD Console

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;36i=40;33:so=01;35:do=01;35:bd=40;33;01
:cd=40;33;01r=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.
 
1 members found this post helpful.
Old 09-14-2005, 04:19 AM   #3
gani
Member
 
Registered: Jun 2004
Location: Metro Manila, Philippines
Distribution: Linuxmint, Slackware
Posts: 356

Original Poster
Rep: Reputation: 34
Quote:
Put it now in your ~/.profile ( or /home/.profile):
Sorry, it should be /home/username/.profile
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
framebuffer console for OpenBSD? lazlow69 *BSD 5 08-29-2018 05:47 AM
[OpenBSD 3.7] console change noir911 *BSD 2 08-03-2005 05:11 PM
OpenBSD - Where can i get OpenBSD 3.7 ISO CD -- Please help me b:z Linux - Software 5 04-08-2005 07:09 AM
OpenBSD - Where can i get OpenBSD 3.7 ISO CD -- Please help me b:z Linux - Software 1 04-07-2005 08:46 AM
[openbsd] more virtual console noir911 *BSD 1 09-02-2004 02:13 PM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 03:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration