When I do an ls of a directory and a shell script is listed as a directory item, is there a way I can have a visual indication that it is a shell script ?

For example:

From /opt/local/bin 
ls -l

Displays port from MacPorts as an ordinary item:


Can I have color coding, bold or some other way to see this ? I know I can use file to check if it's a script, executable, etc., but that's an extra command I have to issue and is no better than trying to run port and then getting an error and typing ./port.



3 Answers 3


Try typing ls -G in terminal, you should see colored listings by file type. If the scripts aren't being shown in a different color, this means that they are not marked as executable, so you will need to type sudo chmod +x <filename> to make them so. Then they should appear in a different color as opposed to directorys etc.

If you prefer not to always type ls -G then you can put the following command in your .bashrc file in your home directory alias "ls"="ls -G" Then restart terminal and you should see colored output whenever you just type ls

  • 2
    I'm pretty sure there is an environment variable that controls ls's color options. That would be the better thing to change
    – Fake Name
    May 25, 2011 at 1:56
  • @Fake Name - Thanks guys! This is what I was looking for. May 25, 2011 at 11:09

You can set this in your ~/.bash_profile file to enable colors equivalent to ls -G:

export CLICOLOR=1

As I’m not a fan of colours — they depend on the current terminal colour settings to look good — I prefer to use ls -F.

Borrowing from SCO Unix, I define an lf alias in ~/.bashrc:

alias lf="ls -F"

Executable files such as shell scripts show up with a * at the end of their names. Similarly, / for directories and @ for symbolic links.

  • Thanks! The color highlighting was what I was looking for, but I had no idea of the asterisk option - I'll add this to my toolkit. May 25, 2011 at 11:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .