Graphical Directory Tree

xtree - graphical directory tree

This utility provides a simple graphical tree of your directory structure, using xterm escape sequences to access alternate character sets for generating the tree characters. The graphics are not terribly impressive, so if you want to strip out the characters and replace them, you probably don't need to be using an xterm for your terminal set-up.

I modeled the program after two things: first is DOS's vtree program (and other similar programs) that generate a graphical directory tree. The second is the Unix utility ls, from which I copied several of the options.

I don't know if anyone will find this useful, but I wrote it to play around with the directory functions, and this is what I ended up with. I have actually found it useful for searching for files that are buried within a deep directory structure for a large project, so maybe it does have merits other than cuteness.

You may feel free to use, distribute, and modify the program freely. I ask only that you give me credit, tell me if you find it useful, and tell me about any interesting modifications you make.

I have run this program on: DECstations 2100, 3100, and 5000
Sun Sparcstations
IBM RS/6000
HP 700 series (see Bugs below)
SGI Irix (see Bugs below)

It should run on most Unix derivatives, though. Click here to download a gzip'ed archive. If you can't read this format and would like a copy of the program, you can try searching comp.sources.unix archives or send me mail.

Usage

xtree [options] <dir-list>

options:
          -a | -A   list "hidden" files as well, like 'ls -A,'
                    . and .. are never listed in subdirectories, but
                    they are legal in <dir-list>.

          -F        use the trailers to indicate file type, identical
                    to ls (/ directory, * executable, @ symbolic link,
                    = socket)

          -L        follow symbolic links as if they were hard

          -d [n]    limit the depth of traversal to n, 1 by default
                    I must say that 'xtree -d' with no n is NOT
                    interesting, but then again, neither is 'ls -d'

          -e        interpret all following arguments as <dir-list>,
                    for directories that begin with '-'

<dir-list>:
          the directory list can be empty, and '.' (current directory)
          is the default.  Directories other than subdirectories of
          the current directory can be given.
Bugs
There is a bug on the SGI that occurs sometimes, causing a segmentation fault. The HP I have does not recognize the character set that I use for the tree structure, so it doesn't look very impressive.

The escape sequences are specific to xterm, supposedly, which limits the program's portability to non-Unix systems. They could easily be removed, however.

They also mean that the output of this program is only useful for viewing on screen, and only by programs that will interpret the escape sequences. Shells, more, and cat with no options are all fine.

If you care to see the actual characters, or read through the source code, use 'cat -v' or emacs or vi.


If you like the program and use it, please let me know.

Mark Livingston
Duke University '93 (location when program was written)
Dept. of Computer Science
Univ. of North Carolina '98