Charly’s Column – colorls

Color Cast

Article from Issue 211/2018
Author(s):

The first time in our lives we got to a black-and-white Linux or Unix shell, most of us probably typed ls first. In a mixture of nostalgia and the knowledge that life is colorful, columnist Charly Kühnast plays a colorful trump card with colorls.

colorls [1] is written in Ruby. If you don't have this language on your system yet, install it quickly:

sudo apt install ruby ruby-dev ruby-colorize

Then you download a character set that you really like from Nerd Fonts [2] – say, Roboto Mono Nerd Font Regular. After unpacking the ZIP file, I moved the character set to the /usr/share/fonts/truetype/roboto/ directory on my Ubuntu desktop; users of other distributions may need to change this path.

Why do I even get this font when there are a few dozen others preinstalled? Because Nerd Font's character sets are more extensive, containing more symbols, special characters, glyphs, and emojis than usual (Figure 1). Now I select the new font in my terminal's preferences. This fulfills the preconditions, and I can proceed to install colorls by typing:

sudo gem install colorls
Figure 1: On Nerd Font's Cheat Sheet [3], you can see the extended character sets.

The developers know that nobody types colorls 50 times a day. I recommend that you create an lc alias in your ~/.bashrc:

alias lc='colorls'

If you use a light terminal background, you should always specify --light or, preferably, make it permanent by appending it to the .bashrc alias. The output then resembles that in Figure 2 – note the cute icons and bright colors. Light-shy workers can choose a variant optimized for dark terminals by specifying --dark.

Figure 2: colorls --light prints files and directories in a light color scheme.

No Blind Faith in Color

Speaking of the downside: colorls is a new implementation of ls, which does not implement all options identically and others not at all. My big favorites -l and --sort=size fortunately work. If you type -f, colorls only displays files; -d only displays directories. If I want to see both, I have the choice between --sd (directories first – note the two dashes!) and --sf (files first).

If you would like a brightly colored ls, but have problems with colorls because of missing parameters, schedule a test run with exa [4], which doesn't offer any fancy icons but does support almost all the ls parameters and adds some on top. Especially with the defaults, exa impresses – for example, the -h parameter (human readable), which outputs file sizes in human-readable units instead of bytes, is implicit.

The Author

Charly Kühnast manages Unix systems in the data center in the Lower Rhine region of Germany. His responsibilities include ensuring the security and availability of firewalls and the DMZ.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Charly’s Column: Cluster SSH

    Charly doesn’t relish the idea of searching through the logfiles of a dozen proxy servers when page requests fail. Now that he has deployed Cluster SSH, he can pull the strings on many machines at the same time.

  • The sys admin's daily grind: Smorgasbord

    Sys admin columnist Charly Kühnast has an electronic note box in which he collects ideas and small snippets of code. He calls it his "quarry" and is taking this opportunity to offer up some collectors' items to regular readers.

  • Charly's Column: Fish

    Columnist Charly serves up Fish as the "shellfish" of the day. His conclusion: tasty, but not something you would want every day.

  • Charly's Column: PomodoPi

    Charly starts the tomato and dill season aboveground with a traffic light and underground with a soaker hose, along with assistance from two gardeners and the ubiquitous Raspberry Pi board.

  • Charly's Column

    Twitter, so everyone says, is modern, fun, sociologically illuminating and otherwise useless. Even Charly feeds a budgie – but at the console, it's a question of style.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News