Free Downloads, Community Forum,
FAQs and Developer Resources


Make /Tools Your Home | Link to us

Today's posts | Posts since last visit | Most Active Topics

All Forums Register Login Search Subscriptions My Profile Inbox
Tool Warehouse FAQs Resources Help Member List Address Book Logout

bash with colors in a shell

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [SFU / Interix / SUA Technology] >> Tools Discussion Forum >> bash with colors in a shell Page: [1]
Login
Message << Older Topic   Newer Topic >>
bash with colors in a shell - Jul. 12, '04, 4:57:06 PM   
jumphigh

 

Posts: 61
Joined: Jul. 10, '04,
From: Germany
Status: offline
Hello forum,

When I'm working on a Linux machine I mentioned that bash uses different colors when doing a ls etc. So you can distinguish normal files and directories pretty fast without the need of ls -l.
Although Rodney stated in an other thread at the beginners forum that the shipped XTerm is only b&w, but in a posix shell mutt should show colors.
So I asked how to set up bash for using colors?

Thanks,
Andreas
Post #: 1
RE: bash with colors in a shell - Jul. 12, '04, 6:56:50 PM   
Rodney

 

Posts: 2916
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
Well when you're looking for ls to give colour o/p you need a
colour enabled ls. The shell doesn't have much to do with that.
If you are looking for bash to put colours in your prompt or something
like that you can do it with escape codes in the prompt setting.

I'll point out for ls you can determine what each file is without using
the "-l" option. Instead use the "-F" option. It's a standard, tigher notation
that similar to using colours. There is also the alternative utility lc that
is available in the /Tools warehouse. It divides the output by file type and allows
you to select showing or not different file types.

< Message edited by Rodney -- Jul. 12, '04, 6:58:28 PM >

(in reply to jumphigh)
Post #: 2
RE: bash with colors in a shell - Jul. 13, '04, 8:30:56 AM   
cortez_

 

Posts: 330
Joined: Mar. 27, '04,
From: Poland
Status: offline
The solution is:
Take the fileutils package from www.gnu.org -> compile the ls utility by yourself
Then it will have the colours enabled.

The gnu ls as far as I remember builds without problem

(in reply to Rodney)
Post #: 3
RE: bash with colors in a shell - Jul. 13, '04, 6:46:37 PM   
jumphigh

 

Posts: 61
Joined: Jul. 10, '04,
From: Germany
Status: offline
Oh, I see, Interix was shipped with raw Unix tools :-(
There is nothing with eyecandy ;-)
Btw, after posting the question, I also thought that ls would be the problem.

Thanks for your fast help,
Andreas

(in reply to cortez_)
Post #: 4
RE: bash with colors in a shell - Jul. 13, '04, 7:43:55 PM   
Rodney

 

Posts: 2916
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
The new ls I just added to the ftp site (see the Announcement Forum)
does colors.

(in reply to jumphigh)
Post #: 5
RE: bash with colors in a shell - Jul. 15, '04, 2:35:55 PM   
jumphigh

 

Posts: 61
Joined: Jul. 10, '04,
From: Germany
Status: offline
Hello Rodney,

I gave a try to your new ls. OK, it works, but that's not that piece of software you want.

Do a "ls |more" and coloring is broken! You see the escape commands in the more output. When setting POSIX-Terminal-Window settings via Windows, like text to black and background to white, you can't use this ls because it always set background to black, and black on black is not so good for reading . The LS_COLOURS shell var doesn't support different background colors, or am I wrong? The man pages say nothing about that.

I checked the ls on a Linux machine, and this version uses a file called DIR_COLORS in /etc. The man pages say something like FSF, but I hope it's the same as the ls from the GNU fileutils. I loaded this package and give it a try now.

CU,
Andreas

(in reply to Rodney)
Post #: 6
RE: bash with colors in a shell - Jul. 15, '04, 2:54:58 PM   
Rodney

 

Posts: 2916
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
Depends on the colour of your terminal :-)
I have blue, red, yellow and green ones.
The LS_COLOURS supports foreground colours right now. I'll look at extending it
to have optional background colors.
WRT more: it's nothing that ls is doing. You'll find this with
which program you use. And more is the same as less BTW. So the
result will be the same with any app piping to it.

(in reply to jumphigh)
Post #: 7
RE: bash with colors in a shell - Jul. 15, '04, 3:10:25 PM   
jumphigh

 

Posts: 61
Joined: Jul. 10, '04,
From: Germany
Status: offline
quote:

ORIGINAL: Rodney
WRT more: it's nothing that ls is doing. You'll find this with
which program you use. And more is the same as less BTW. So the
result will be the same with any app piping to it.


I know that! But on the said Linux machine you can do a ls with a more or less without problems! If you pipe the ls output colors are disabled and a normal ls shows colors.

(in reply to Rodney)
Post #: 8
RE: bash with colors in a shell - Jul. 15, '04, 3:19:50 PM   
Rodney

 

Posts: 2916
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
Easy enough change. I thought you were wanting the colours to survive in more.

(in reply to jumphigh)
Post #: 9
RE: bash with colors in a shell - Jul. 15, '04, 3:50:15 PM   
jumphigh

 

Posts: 61
Joined: Jul. 10, '04,
From: Germany
Status: offline
No no, I just asked because I remembered the colors on Linux. I lived with the shipped ls, and now I know the -F flag, so I made a alias for ls. But it was very kind of you porting the new ls so fast.

Now I'm trying to build the GNU coreutils or the fileutils, but configure stops with an error "error: could not determine how to read the list of mounted filesystems". I hate these command line tools. How to disable the mount check???

@cortez: How do you built your GNU ls without errors?

(in reply to Rodney)
Post #: 10
RE: bash with colors in a shell - Jul. 16, '04, 8:30:15 AM   
cortez_

 

Posts: 330
Joined: Mar. 27, '04,
From: Poland
Status: offline
I have just commented out the ./configure part where it checks for the mounted filesystems. then it compiled with no errors.
Actually the comment in the ./configure script says that that section needs to be corrected because it halts unnecesarily when it's not possible to detect the mounted filesystems.

(in reply to jumphigh)
Post #: 11
RE: bash with colors in a shell - Jul. 16, '04, 9:21:11 AM   
minameismud

 

Posts: 14
Joined: Jul. 13, '04,
Status: offline
mmm...thread-jacking

on the GNU fileutils configure, i get an error that says it couldn't determine the build type. not being very *nix savvy, i cannot find where in the configure script it's actually doing the comparison. did anyone else have this problem?

(in reply to cortez_)
Post #: 12
RE: bash with colors in a shell - Jul. 16, '04, 10:13:10 AM   
Rodney

 

Posts: 2916
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
Likely it's an old config.guess file.
Grab a never version at ftp://ftp.interopsystems.com/pub/config.guess
and clobber the one you currently have. Then run configure again.
This is the better way than doing a command line override.

(in reply to minameismud)
Post #: 13
RE: bash with colors in a shell - Jul. 16, '04, 11:43:49 AM   
Rodney

 

Posts: 2916
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
Back at the original thread.

I want to point out that with the new ls the colour you specify
can be a background colour, it doesn't have to be a foreground colour.

(in reply to Rodney)
Post #: 14
RE: bash with colors in a shell - Jul. 21, '04, 11:54:50 AM   
jumphigh

 

Posts: 61
Joined: Jul. 10, '04,
From: Germany
Status: offline
@Rodney:

I built the GNU fileutils, and now I'm using this ls with the help of dircolors utility. Nice in interix terminal, and also with improvements in b&w xterm.
First I tried to built the complete coreutils from GNU, but I discovered a strange bug when doing the ./configure:
Configure checks if getcwd can handle paths longer than PATH_MAX. On the first try I got a BSOD in ntfs.sys, the second one crashed WinXP with a frozen desktop, no reaction to keys, no more a mouse pointer visible! What the hell is this? Should I change to Linux?


@cortez_
The build was easier than I expected, although after commenting out the mount check, there were more errors:

1. mknod needs makedev, but on Interix it was named mkdev. I could figure it out with google, so it was easy to fix.

2. shred and sync don't link, because they need a sync/_sync function. Which lib contains that? I can't find it in the fileutils package itself.

Fortunately ls and dircolors was built before, so I didn't need to built manually.

(in reply to Rodney)
Post #: 15
RE: bash with colors in a shell - Jul. 21, '04, 12:40:17 PM   
Rodney

 

Posts: 2916
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
> On the first try I got a BSOD in ntfs.sys, the second one crashed WinXP

Interesting. Not anything I can fix (alas). You can report it through to MS
support. I'm assuming you have all the latest patches.

> because they need a sync/_sync function

There is no sync() function. There is fsync() instead.
So you can change the code to use fsync() if possible or #if 0 it.
Since NTFS is journaled #if 0'ing shouldn't be a problem.

(in reply to jumphigh)
Post #: 16
RE: bash with colors in a shell - Jul. 24, '04, 2:06:24 AM   
wkg@usa.net

 

Posts: 2
Joined: May 22, '04,
Status: offline
How come the colors don't show up in X-terms? Is there an easy switch to throw?

(in reply to Rodney)
Post #: 17
RE: bash with colors in a shell - Jul. 24, '04, 2:17:43 AM   
Rodney

 

Posts: 2916
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
> How come the colors don't show up in X-terms? Is there an easy switch to throw?

Because it the original black & white only xterm.
There has been a submission for the rxvt package.
I'm hoping to vet it before starting vacation on Monday.

(in reply to wkg@usa.net)
Post #: 18
Page:   [1]
All Forums >> [SFU / Interix / SUA Technology] >> Tools Discussion Forum >> bash with colors in a shell Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Search All Forums -

Advanced search


SPONSORS



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.063