sl takes the most common use of Unix ls, to display the files in a directory compactly in multiple columns, and makes it substantially more useful.
sl groups files by purpose so you can mentally organize many files quickly; for instance, it collects HTML and PHP files together, as opposed to leaving them mixed up with supporting images, CSS, and JavaScript. sl points out interesting files, which include those that have been recently modified, read relatively recently, are relatively large, have warnings, or need to be checked in to or out of version control.
sl is also aesthetically pleasing due to attention to layout and filtering as well as limiting color and text annotations to salient information.
ls vs sl on WWW site:
sl on a software development directory:
sl on a collection (photos, audio, video, even apps):
On this directory of music, which is managed by iTunes, we see all the albums by an artist.
sl also shows /number of songs in each album,
the relatively recent CD rips (which not coincidentally correspond to the latest two albums),
which we ripped about 2 months ago (58 days) and 7 months ago (228 days).
The summary line at bottom shows the total number of CDs and the (total number) of songs.
Note that the directories were determined to hold audio material,
and sorting works as it should with inital "The"s ignored.
This display is useful for other kinds of hierarchy.
8.jpg before 10.jpg — no need for leading 0s just for sorting)
large files relative to other files in that directory (indent by a space — easy to pick out against column edge)
ls -F): directory/, link->, executable*, special_
ls -G, though more subtle since have groupings and warnings)
-age), recently changed (<age, with < implying it may be earlier if a download or sloppy copy reset the last modified time), and relatively large (size-in-bytes).
Per-file customizations can display, for example, latest build time and build number next to Ant build.xml, count of critical bugs filed against source code file, number of lines in TODO list, warning if HTML has not been validated, you name it.
/number of files in subdirectories, which can be a useful if rough survey (this is not slow)
TOSORT/27, tests/27, Yosemite 2007 photos/316 vs Detroit photos/2
ls -B), generated (Java .class, C .o), C .h, Macintosh Desktop DB, TAGS
audiobook ch 01.mp3 ... audiobook ch 27.mp3) and condense to first one plus count
DSC00423.jpg, DSC00424.jpg, DSC00427.jpg ... DSC01072.jpg ⇒ DSC00423.jpg...227. Also look at /dev.
-only command-line option to distill the listing to only distinctive files.
A file is considered distinctive if it's: recently changed, recently read, a warning, or spot info.
sl -only on /usr/bin
and OS X /Library/Fonts can be interesting.
ls dictated by the single longest filename in the directory), giving a more natural appearance and freeing space for more columns
rwx-wx-wx
sl does not replace ls.
Use ls to see all files and full metadata.
for OS X, Solaris, Unix, and GNU/Linux
Licensed under the GNU Public License version 3.
NO WARRANTY.
Install:
/usr/local/bin or ~/bin.
chmod +x download-dir/sl unalias sl rehash
which tclsh comes up empty).
Install into /usr/local/bin or change the first line of the sl script.
Tcl is already installed in OS X.
Use: Now more-useful listings are as convenient to type as the usual ls.
sl directory-path
Convenience: Automatically see an overview and interesting files when switching to a new directory:
alias cd 'cd \!*; sl' alias pd 'pushd \!*; sl' alias pdo 'pushd \!*; sl -only'
Customization is done via a startup file, at the path ~/.sl.tcl.
You can control colors, new suffixes, localization of the most used text, switches that control system operation,
and even exactly what is shown for every file.
For example, here's a custom color scheme that makes files and directories brighter
and blends the text annotations into the background.
The startup file is executed as Tcl code, so you can implement substantial changes, such as adding support for another version control system. Rather than hacking the source code, it is better to put customizations in the startup file so that you can easily update to new versions without reapplying your hacks. Tcl lets you go so far as redefining whole procedures, so any change you want can be done in the startup file.
.sl.tcl sample startup file, download to your home directory.
It shows how to make many of the most likely changes,
as well as how to turn on features that are too mind blowing to be the default settings, including prefix and suffix elision.
Troubleshooting:
^[[31m, enable color for your terminal or turn off color in your startup file.
less, set the LESS environment variable to include --RAW-CONTROL-CHARS.
no such file or directory, but file definitely exists.
If you have a legacy filesystem with filenames that are not encoded in Unicode UTF-8 (or ASCII, which is a subset of UTF-8),
you should migrate the names to UTF-8 with a tool such as convmv.
sl tries to handle this situation, but for paths passed to it on the command line it is already too late.
ls was a misspelling.
In some systems, it resulted in a Command not found error.
Some shells prepared for this and aliased the transposition and other misspellings to in effect autocorrect to what the user meant to type.
If the output still looks like ls, it's probably an alias.
You can unalias in open terminals and take out the line in the shell startup file.
In another case, a Linux distribution surprised you with ASCII art of a train.
You can delete it, or if an ASCII train is a key part of your problem-solving toolkit you can rename it.
Known bugs:
Send suggestions and bug reports to
Invented by Tom Phelps on December 30, 2011.