Blinking snake

CDLIST 1.0

God N, reversed

Name

cdlist - Directory Management Package for Korn Shell


[Syntax] [Description] [Download and Installation] [Detailed Function Descriptions] [Environment Variables]
[Examples] [Files] [Platforms Supported] [Author, Copyright & Disclaimer]

Syntax

Cdlist exposes the following functions to a sourcing ksh instance:

Description

Cdlist is a directory management package contained in the file cdlist.ksh which must be sourced to be useful:
    $ . cdlist.ksh
    $
It’s usually a good idea to put the source command as the last command in your $ENV file (a file sourced by a login ksh instance if the instance proves to be an interactive shell). Doing so will export necessary variables and functions for use and (in the case of the functions) aliasing, confined only to interactive shells.

Cdlist provides several features not found in other directory history management packages.

Download and Installation

The latest version of cdlist can be downloaded from www.pauahtun.org/pub/cdlist.zip; the zip file includes this documentation.

To install, simply unzip cdlist.zip anywhere you want, and then copy cdlist.ksh in a convenient place, such as your home directory, or some special subdirectory of ~. In your $ENV file, add this line at or near the end:

	. cdlist.ksh
    
If you are running on a Windows95/98/NT machine, you should probably change the above to:
	export NULLDEV=c:/dev/null # Or whereever you happen to have a /dev/null. ...
	export <any other variables you choose to modify>
	export <see the Environment Variables section>
	. cdlist.ksh
    
If you have directories that you wish to be included in the directory list whenever an interactive ksh session is started, place the directory names in a file named .preloaddirs in your home directory. Edit the file, and place all the directories on a single line, separating individual names with the | character. For example, the line:
	d:/Users/Ivanlan|d:/Users/Ivanlan/KshStuff|e:/|e:/DB|e:/Maya|e:/inetpub/wwwroot|k:/Program Files
    
is in my .preloaddirs file on one of my Windows NT machines.

Detailed Function Descriptions

cd

Syntax: cd or cd <directory>
An alias for an internal function, which performs an unaliased cd; searches the exported array variable $_ll for a match for the new current directory. If no directory is specified, ~ becomes the current directory. The current directory before the cd becomes $_oi, used in the bk function. If a match is found for the new current directory, nothing else is done; otherwise, the new current directory is stored in the array variable $_ll. All directories in the $_ll list are made available in the environment under names following the pattern $dn, where n is the index of the directory in the array variable $_ll. The umask is set appropriately.

cdi

Syntax: cdi index
Searches for index (a number greater than or equal to 0) in the current directory list. If found, cds to that directory and performs all other cd functions too. My preferred alias for this function is “@”, so that, for example, “@ 0” sets the current working directory of my shell to my home directory (0 is, by default, the index of $HOME).

cli

Syntax: cli index
Clears the directory at index and resets the $_ll array variable to eliminate index discontinuities.

up

Syntax: up
Performs a cdi to the next numerically greater index in the directory list; on overflow, reverts to index 0.

down

Syntax: down
Performs a cdi to the next numerically lesser index in the directory list; if the index would become < 0, changes to the highest index in the directory list.

bk

Syntax: bk
Changes to the last visited directory in the list, effectively swapping the values of $_i and $_oi.

saveloadfile

Syntax: saveloadfile <file>
Writes the entire directory list array to file, or to ~/.preloaddirs if no file is specified. This is never performed automatically, so that the contents of ~/.preloaddirs may be preserved across sessions.

overloadfile

Syntax: overloadfile <file>
Reads file, or ~/.preloaddirs if file is not specified, converting the contents to an array variable. The syntax of the file is extremely simple; it’s just a single line containing directory names separated by ‘|’ characters.

cdl

Syntax: cdl
Displays the entire directory list, one line per entry. Directory entries are numbered, starting with 0, representing the index of that directory in the $_ll array. The current directory is marked with the $blank$arrow combination (Green and black checkerboard characterBlack arrow on green background). The last visited directory is marked with the $foobar character (Yellow diamond on brick background, Red happy face on black background or Blue diamond on green background). If the current and last directories are the same, this is marked with the $foobar$arrow (Yellow diamond on brick backgroundBlack arrow on green background) combination.

Sample foobar, blank and arrow usage

Environment Variables

$NULLDEV

If this variable is set, its value is used instead of /dev/null.

$OS

If this variable is set to a value containing the string “Windows”, then the internal variable _igncase is set, and directory list matches and searches are case-insensitive. On Windows95/98, you may need to set and export this variable in your .profile yourself, due to Microsoft inconsistencies.

$insideumask

The umask for directories that have your username somewhere in the path; if not set in the environment, the default value is 22.

$outsideumask

The umask for directories that do not have your username somewhere in the path; if not set in the environment, the default value is 2.

$arrow

Current directory indicator; should be the visual equivalent of three characters long. If not set in the environment, a default value is supplied: Black arrow on green background

$foobar

Last directory visited indicator; should be the visual equivalent of one character long. If not set in the environment, a default value is supplied: Red happy face on black background, Blue diamond on green background or Yellow diamond on brick background

$blank

Filler character; should be the visual equivalent of one character long. If not set in the environment, a default value is supplied: Green and black checkerboard character

$_ll

The array variable containing the entire list of visited directories; it’s exported, but shells receiving the export cannot read the values contained within. Controlled entirely by cdlist.

$_i

The index of the current directory in $_ll; can be used as a read-only variable, as in $PS1, but otherwise controlled entirely by cdlist.

$_oi

The index of the last visited directory in $_ll. Controlled entirely by cdlist, although it can also be used as a read-only variable.

Examples

Example cdl usage in a ksh window, Windows
cdl in a ksh Window

Directory environment variables $d0-$d5
Directory Environment Variables $d0-$d5

cdi (aliased to “@”) in a ksh Window
cdi (aliased to “@”) in a ksh Window

How to use the Directory Environment Variables
Using the Directory Environment Variables

Files

Platforms Supported

Any platform that supports Ksh with array variables. The package was developed under U/WIN, which is an implementation of Ksh93 by David Korn (available at www.research.att.com). It was then transplanted, without change, to the UnixWare® implementation of Ksh88 and to the MKS version of ksh (available at www.mks.com). The only changes required were those specific to Windows.

cdlist also works well with pdksh, available at several locations on the internet.

Author, Copyright & Disclaimer

Cdlist program and documentation copyright © 1998 by Ivan Van Laningham
Home page: http://www.pauahtun.org God N

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee or royalty is hereby granted, provided that the above copyright notice appear in all copies and that both the copyright notice and this permission notice appear in supporting documentation or portions thereof, including modifications, that you make.

THE AUTHOR IVAN VAN LANINGHAM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE!

Previous Page
Table of Contents
Next Page

Main web site:  http://www.pauahtun.org

Valid HTML 4.01 Transitional