Utilities

colorls – turbocharged alternative to ls

Last Updated on August 11, 2021

In Operation

To invoke the program, you enter the command “colorls” at a shell, together with some optional flags. But it’s much more efficient to create an alias (or a few) with some common flags you regularly use. Creating an alias is straightforward. For example, if you use Bash as your shell, edit .bashrc with your favorite editor, and append the following line:

alias la='colorls -lA --sd'

Then either log out of the shell, or run $ source .bashrc.

Here’s some example output from colorls, invoked, courtesy of our alias, by typing la at a shell. With our alias, colorls is automatically invoked with the --sd flag. This is a sorting option that groups directories first. The -lA flag uses a long listing format showing all entries (with the exception of . and ..).

colorls
Click for full size image

From left to right, we see the permissions attached to each file, the number of hard links, the owner name and the owner group.

The 5th column shows the file size. Note that colorls displays different colors for large file sizes (depending on whether the file is large, medium, or small). All three types are shown in our image. The next five columns provide the time of last modification for each file. In our example, the timestamps are all in the same color, but if the file was not modified in the last 24 hours, the timestamp is displayed in a darker shade.

The second to last column depicts a small icon which makes it easy to identify the type of file. Remember a directory is just a special file. The final column displays the file name. It’s regrettable that specific filetypes are not colored differently.

colorls - report
Click for full size image

We can generate a report by appending the --report flag. This displays a summary of the files.

In the example (shown in the image to the right), the report shows 3 folders (directories), 14 recognized files, and 0 unrecognized files.

Listing the folders, recognized files and unrecognized files in separate lines is not very space efficient, but it’s only a minor issue.

colorls - tree
Click for full size image

You can see a tree view of the directory (and sub-directories) with the -t or --tree flag.

There’s lots of other flags that let you specify things like a light/dark color scheme, turn off colorizing the output, different sorting options, and much more.

There’s also a --gs flag which shows the git status for each file.

Next page: Page 3 – Summary

Pages in this article:
Page 1 – Introduction / Installation
Page 2 – In Operation
Page 3 – Summary


Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments