Ryan Rueger

Home · About · Teaching · Keys
Mathematics · Computing · Cycling

Natively pretty printing `ls` output

 

There are a lot of terminal-user-interface tools for displaying files in a more intuitive way. Among them are ranger, vifm and lf.

Of course ls has lots of options to make the output more readable. After the adage “this has more options than ls comes from somewhere”. My default alias is as follows

alias l="ls -lFhG --time-style='+%F-%H%M' --group-directories-first"

where

-l Long format listing.

-F Classify, which appends an indicator to files so they can be immediately identified. This adds a * to executable files, / for directories, @ for symbolic links, | for FIFOs, = for sockets and > for doors.

-h To display the size of the file in a human-readable format.

-G Do not print group names.

--time-style='+%F-%H%M' Prints the time in a specific format.

--group-directories-first List directires first.

Now creating the file

touch ~/----------------

will give output as follows

$ l ~/
drwxr-xr-x 1 user 64 2022-01-02-1801 dir1/
drwxr-xr-x 1 user 64 2022-01-02-1801 dir2/
drwxr-xr-x 1 user 64 2022-01-02-1801 dir3/
-rw-r--r-- 1 user 0  2022-01-02-1801 ----------------
drwxr-xr-x 1 user 64 2022-01-02-1801 file
drwxr-xr-x 1 user 64 2022-01-02-1801 executable*
drwxr-xr-x 1 user 64 2022-01-02-1801 symbolic_link -> /other/destination

Of course this separator will only be in your home directory.