coreutils ls color (was: another question...)

Rodolfo Aramayo raramayo at gmail.com
Mon May 9 20:54:12 PDT 2011


Ryan, Alexander,

Ok this is the deal.

To solve the problem you need to add the following into your: "/etc/profile
or ~.profile"

==========
PS1='\[\e]1;My Desk\a\e]2;${PWD}\a\
\e[0;34m\]\
[\t][\u at MYCOMPUTERNAME]\n \#\$ \
\[\e[m\]'
==========

Rationale:

Apple's good old "/bin/ls" is different from GNU's

In Apple's "/bin/ls" the flags are different. For example: ls -alFG gives
you a colorized output in the terminal, of course assuming you allowed color
to be used in: Terminal>Preferences>Settings>"Display ANSI colors"

In GNU's "/opt/local/bin/gls" the flag -G, which in Apple's is "Enable
colorized output" actually eliminates the -Group from the listing, -G =
--no-group and GNU's ls does not have a flag equivalent to the "-G" flag in
Apple's "ls"

Which explains why Groups were lost...on my listings

Simply installing coreutils changes nothing.

The terminal uses Apple's "ls", for example and "cat "and so on.

To use GNU's ls you need to either create an alias, example alias ls="gls"
OR what I did as recommended during the Ports installation, added the
"export PATH=/opt/local/libexec/gnubin:$PATH" to /etc/profile or ~.profile.

When you do that, Terminal replaces Apples basic stuff and uses GNU's "ls"
and other programs as specified in "/opt/local/libexec/gnubin/ls" for
example

As a result you lose color and as much as I tried, simply using: ls --color
does not work.

The confusing part  for me was that using ls -G was not working either for
reasons explained above.

Yes there is a ton of documentation about "dircolors" and LS_COLOR and
--color, but I was unable to get that to work.

I am sure there is a way, but I could not find it...

So that is it and I Thank Doug Barton for his guidance (
http://dougbarton.us/Bash/Bash-prompts.html)

--Rodolfo



On Mon, May 9, 2011 at 07:22, Ryan Schmidt <ryandesign at macports.org> wrote:

> Please keep this discussion on the mailing list by using Reply All instead
> of Reply.
>
> On May 9, 2011, at 07:11, Rodolfo Aramayo wrote:
>
> > Ryan Schmidt wrote:
>
> >
>
> >> You're sure you don't need to specify "--color" as well? That seems to
> work for me.
> >
> > Before, after installing coreutils, I did not specify the " export
> PATH=/opt/local/libexec/gnubin:$PATH" path. I had created a series of
> aliases to force Bash to use some of the the gnu stuff. Color was there,
> because color comes standard with the Apple installation.
> >
> > But it looks to me that by specifying this gnubin path not only we lost
> color by default but also we lost a column specifying "Group" as well
> >
> > It would be nice if you could share the way you activate color in your
> .profile file
>
> I do not use coreutils' gls nor do I use colored listings (except in
> response to your email, to verify that "--color" worked) so I don't know how
> to help you, beyond suggesting that you read the gls manpage for ideas.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-users/attachments/20110509/a0f18c8d/attachment.html>


More information about the macports-users mailing list