dim

copyright 2001 by Matt Chisholm - matt (at) theory.org
This software is licensed under the GNU GPL.

dim has been reimplemented in Python and is now available as part of the shelltools package. This software is no longer being maintained.

"dim," short for "directory image," is a demonstration of an alternative layout algorithm for listing files in a directory.

dim sorts files by filename and by extension. All the files with a given extension will be in the same column. All the files with a certain name (aside from the extension) will be in the same row. dim employs a semi-intelligent algorithm to first construct a grid of files, and then collapse the grid as much as possible, eliminating most of the white space. The algorithm is very variable, and doesn't always produce attractive output.

Notice, however, that the dim output immediately conveys which groups of files are present in the directory. The *.c, *.h, and *.o files, for example, are immediately grouped into columns, and it is immediately obvious which *.c files, for example, have corresponding *.o files.

If you are looking for a particular file by name, you can still find it with dim, as the files are listed alphabetically in the vertical direction.

By comparison, ls sorts files by some parameter, usually alphabetically by name, although it can also list files by date, size, and extension. dim can also include the file size and modification dates.

Perhaps the best way to explain would be a demonstration. Here is the output of dim and ls, on the exact same directories, in an 80-character wide terminal.

dim output ls output
% dim /usr/src/linux/arch/i386/kernel/
Makefile     apm.c
             bios32.c                  bios32.o
             bluesmoke.c               bluesmoke.o
entry.S                                entry.o
head.S                                 head.o
trampoline.S i386_ksyms.c              i386_ksyms.o
             init_task.c               init_task.o
             io_apic.c
             ioport.c                  ioport.o
             irq.c        irq.h        irq.o
                                       kernel.o
             ldt.c                     ldt.o
             mca.c
             mtrr.c
             process.c                 process.o
             ptrace.c                  ptrace.o
             setup.c                   setup.o
             signal.c                  signal.o
             smp.c
             sys_i386.c                sys_i386.o
             time.c                    time.o
             traps.c                   traps.o
             visws_apic.c
             vm86.c                    vm86.o
	    
% ls  /usr/src/linux/arch/i386/kernel/
Makefile     head.S        ioport.o  mtrr.c     signal.o      traps.o
apm.c        head.o        irq.c     process.c  smp.c         visws_apic.c      
bios32.c     i386_ksyms.c  irq.h     process.o  sys_i386.c    vm86.c
bios32.o     i386_ksyms.o  irq.o     ptrace.c   sys_i386.o    vm86.o
bluesmoke.c  init_task.c   kernel.o  ptrace.o   time.c
bluesmoke.o  init_task.o   ldt.c     setup.c    time.o
entry.S      io_apic.c     ldt.o     setup.o    trampoline.S
entry.o      ioport.c      mca.c     signal.c   traps.c
	    
% dim /usr/local/src/xscreensaver-3.28/utils/
Makefile         Makefile.in
README
ad2c
alpha.c          alpha.h                           alpha.o
colors.c         colors.h                          colors.o
compile_axp.com
compile_decc.com
erase.c          erase.h                           erase.o
fade.c           fade.h                            fade.o
grabscreen.c     grabscreen.h                      grabscreen.o
hsv.c            hsv.h                             hsv.o
logo.c           logo.eps         logo.gif         logo.o           logo.xpm         
overlay.c                                          overlay.o
resources.c      resources.h                       resources.o
sgivideo.c       sgivideo.h                        sgivideo.o
spline.c         spline.h                          spline.o
usleep.c         usleep.h                          usleep.o
                 utils.h
                 version.h
visual.c         visual.h                          visual.o
visual-gl.c                                        visual-gl.o
vms-gtod.c       vms-gtod.h
vms-strdup.c     vroot.h
xdbe.c           xdbe.h                            xdbe.o
xmu.c            xmu.h                             xmu.o
xshm.c           xshm.h                            xshm.o
yarandom.c       yarandom.h                        yarandom.o
	    
% ls /usr/local/src/xscreensaver-3.28/utils/
Makefile          erase.o       logo.xpm     usleep.o      xdbe.o
Makefile.in       fade.c        overlay.c    utils.h       xmu.c
README            fade.h        overlay.o    version.h     xmu.h
ad2c*             fade.o        resources.c  visual-gl.c   xmu.o
alpha.c           grabscreen.c  resources.h  visual-gl.o   xshm.c
alpha.h           grabscreen.h  resources.o  visual.c      xshm.h
alpha.o           grabscreen.o  sgivideo.c   visual.h      xshm.o
colors.c          hsv.c         sgivideo.h   visual.o      yarandom.c
colors.h          hsv.h         sgivideo.o   vms-gtod.c    yarandom.h
colors.o          hsv.o         spline.c     vms-gtod.h    yarandom.o
compile_axp.com   logo.c        spline.h     vms-strdup.c
compile_decc.com  logo.eps      spline.o     vroot.h
erase.c           logo.gif      usleep.c     xdbe.c
erase.h           logo.o        usleep.h     xdbe.h
	    

The dim algorithm would be particularly useful for organizing icons in a window of a graphical file manager, like gmc or nautilus. It could either be the "clean-up window" algorithm (or one of them), or the default display algorithm.

Get the (perl) program here. Send input, suggestions, death threats, etc. to matt (at) theory.org.


Last modified: Wed May 18 23:50:17 PDT 2005