DaemonForums How to modify the ls command?
 FAQ Search Today's Posts Mark Forums Read

 OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

5th May 2009
 bsdnewbie999 Package Pilot Join Date: May 2008 Posts: 145 Thanked 0 Times in 0 Posts
How to modify the ls command?

ls program in bsd display all the contents in the current directory but some file are directories. I know with the option ls -F can differentiate between them. Then I come out the question, can i modify the ls program to display the directory in color and others remain the same just like Linux.

Last edited by bsdnewbie999; 5th May 2009 at 02:11 PM. Reason: should be program not command.
5th May 2009
 BSDfan666 Real Name: N/A, this is the interweb. Helpful companion Join Date: Apr 2008 Location: Ontario, Canada Posts: 2,223 Thanked 193 Times in 184 Posts

OpenBSD's ls(1) does not support colours, but if really require such a ridiculous feature.. someone has created a modified version, you can find it in the ports tree.

Here is shortcut: sysutils/colorls
6th May 2009
 wraith0x2b Port Guard Join Date: May 2009 Posts: 12 Thanked 0 Times in 0 Posts

To add to what BSDfan666 said, after (or if) you install colorls, you should alias ls to point to colorls
for bash this would mean adding alias ls="colorls" to ~/.bashrc
6th May 2009
 marcolino Real Name: Mark Custom Title Maker Join Date: May 2008 Location: At the Mountains of Madness Posts: 114 Thanked 0 Times in 0 Posts

Code:
alias ls='colorls -G'
__________________
That's nothing a couple o' pints wouldn't fix.
8th May 2009
 Zmyrgel Port Guard Join Date: May 2008 Posts: 26 Thanked 0 Times in 0 Posts

Quote:
 Originally Posted by BSDfan666 OpenBSD's ls(1) does not support colours, but if really require such a ridiculous feature.. someone has created a modified version, you can find it in the ports tree.
Why do you say that color support in ls is ridiculous? I'd say colors quickly indicate which kind of files directory has. It's much easier to read ls output with colors.
9th May 2009
 BSDfan666 Real Name: N/A, this is the interweb. Helpful companion Join Date: Apr 2008 Location: Ontario, Canada Posts: 2,223 Thanked 193 Times in 184 Posts

I beg to differer, that's what file(1) is for.. there is no point arguing though, this is just my personal opinion.
9th May 2009
 Oko Fsck Surgeon Join Date: May 2008 Location: Kosovo, Serbia Posts: 856 Thanked 36 Times in 32 Posts

Quote:
 Originally Posted by BSDfan666 I beg to differer, that's what file(1) is for.. there is no point arguing though, this is just my personal opinion.
It is hard to argue with Ubuntu users who think that the other systems
should behave the same.
9th May 2009
 TerryP Arp Constable Join Date: May 2008 Location: USofA Posts: 1,547 Thanked 112 Times in 104 Posts

Quote:
 Originally Posted by Zmyrgel Why do you say that color support in ls is ridiculous? I'd say colors quickly indicate which kind of files directory has. It's much easier to read ls output with colors.
Actually 'ls -F' is much better IMHO, and much more reliable if you want the information retained when piping data into another program. I've found the '/', '*', '@', '=', '%', and '|' to be excellent visual indicators of things, while file and vi are more useful for inspecting a files contents. The colours are better for ascetics then anything else.

If anyone requires syntax highlighting to write code, they probably do not know how to write code in the first place. If anyone requires colour output to tell directories from files, they are probably a dipstick.

Simple.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest foo'' someone someday shall type supercalifragilisticexpialidocious''.
16th May 2009
 gosha Spam Deminer Join Date: Jun 2008 Location: China Posts: 256 Thanked 0 Times in 0 Posts

Quote:
 If anyone requires syntax highlighting to write code, they probably do not know how to write code in the first place. If anyone requires colour output to tell directories from files, they are probably a dipstick.
This is interesting. As you might all know from my previous posts I'm not a programmer, but after starting to use OpenBSD I also switched to Latex (which, if I understand right, is to some extent a programming language) to get my papers done. Well, I used it in black and white for a long time, then discovered that Vim supports color syntax highlighting, tried it, and found it useful, especially because, for example, you can spot out a \emph{blabla} inside e paragraph quickly.
Now the question: why is using syntax highlighting to be considered a bad habit? And what are the strategies to make do without?
tks
16th May 2009
 ocicat Administrator Join Date: Apr 2008 Posts: 2,935 Thanked 190 Times in 160 Posts

Quote:
 Originally Posted by gosha why is using syntax highlighting to be considered a bad habit?

There is nothing inherently evil about color syntax highlighting, however if it becomes a crutch such that you have to have it available, then this may become a problem when you have to migrate to systems which don't have your specific customizations configured.

I use color syntax highlighting on occasions for similar reasons: it can help bring to focus certain aspects of structure, but I can also live without it. Emacs colors differently (by default) than vim, so because I have spent a lot of time in Emacs lately, suddenly moving to vim initially seems odd. Most editors make the colors configurable, but I don't find the default choices so distasteful in these environments to do anything about it. Besides, on OpenBSD systems, I tend to use mg(1) which doesn't provide color syntax highlighting at all. Also, it's better because it is faster.

I suspect the consternation you may be reading in this thread result from the fact Linux distributions tend to have the output of ls(1) color-coded. Personally, I find this distracting, but that is my opinion, & preference. If others find it helpful, fine. This debate can quickly decay into a religious war which doesn't possess significant value.

Now if you start treading on my ANSI color-fied shell prompt, then those are fighting words.

So it's a question of what has been your experience, & what your choices are based upon that experience. Nothing more. If you like color-syntax highlighting great. If you don't, that's fine too. It's merely a feature.

 Thread Tools Display Modes Linear Mode

 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 On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home DaemonForums.org     News     Forum Announcements     Feedback and Suggestions FreeBSD     FreeBSD General     FreeBSD Ports and Packages     FreeBSD Installation and Upgrading     FreeBSD Security OpenBSD     OpenBSD General     OpenBSD Packages and Ports     OpenBSD Installation and Upgrading     OpenBSD Security NetBSD     NetBSD General     NetBSD Package System (pkgsrc)     NetBSD Installation and Upgrading     NetBSD Security Other Operating Systems     Other BSD and UNIX/UNIX-like     Solaris     Other OS Miscellaneous     Programming     General software and network     General Hardware     Book reviews     Guides     Off-Topic

 Similar Threads Thread Thread Starter Forum Replies Last Post wubrgamer Other BSD and UNIX/UNIX-like 9 22nd April 2009 03:15 AM Dr_Death_UAE FreeBSD Security 5 6th November 2008 09:20 PM anomie Guides 13 16th June 2008 04:26 AM aleunix OpenBSD General 7 15th June 2008 04:32 PM Sunsawe FreeBSD General 5 29th May 2008 05:13 AM

All times are GMT. The time now is 10:55 PM.

 -- DaemonForums Fixed Width 60em -- DaemonForums Fixed Width 80% -- DaemonForums Fluid Width - Contact Us - DaemonForums.org - Archive - Privacy Statement - Top