A nicer ‘ls’ in OSX

If you use the Console frequently in OSX, you will be very familiar with the ‘ls’ command. Here is a quick tip:

Add the following line to the “.profile” file in your home directory (creating the file if it doesn’t already exist):

alias ls="ls -hGlrt"
Note that case is important.

Now, when you type ‘ls’, rather than seeing:

You see the much nicer (IMHO):

Specifically, here are what each of the -hGlrt options do, so you can mix and match as you like:

  1. l : Show a “long form” listing, which includes permissions, dates, and sizes
  2. G : Switch on color output
    (This confuses a lot of people, because on Linux you use the --color option. Many people actually recompile ‘ls’ thinking that color is unsupported, its amazing the time you can save by reading the man page!)
  3. h : Show file sizes in a more human readable form
  4. rt : Sort the files ending with the most recently modified (thanks to Tim for this suggestion!)

Leave a Reply

Your email address will not be published. Required fields are marked *