2002.08.22 CDP 2.31 William W. Patterson Homepage: http://www.komputado.com/softvaro/misc.htm Usage: cdp [options] [drive:][path] This program can be used just like the familiar cd command... mostly... except the DOS version doesn't print the current working directory if no arguments are supplied, and the UNIX version doesn't take you home if no arguments are supplied. Other than that... "cdp \temp" takes you to \temp and "cdp /tmp" will take you to /tmp, as you'd expect. But, before the move is performed, cdp can stash your current location in a safe place... "cdp -p \temp" pushes the current info onto a stack before taking you to the \temp directory. Then you can cd and cdp all over the place, and even "cdp -p" to other places. And when you're ready to return to the last place you stashed, enter "cdp" alone to pop the most recently pushed directory and move back to there. And "cdp" again to move back to the one you pushed before that, and so on and so on. But cdp also offers another handy feature. Except for -p and -h, cdp option letters can be defined for other oft-used directories. This can be done in two ways. If you have a compiler handy, you can code them in and recompile. Or you can define environment variables to define or replace the ones which have already been compiled in. For example, if you do this in DOS: "set cdpt=\temp"; or this in UNIX: "export CDPT=/tmp"; then "cdp -t" will always move you to that temporary directory (cdp doesn't care whether you use slashes or backslashes). And in DOS you can also specify a destination drive with cdp: "cdp c:/backups". Or just a drive alone: "cdp a:" or "cdp -p a:". But, Wait, as they say, There's More! You can combine a relative path designation (or several, though I rarely find that useful) with an option For example, if cdp is set up so that "-t" moves you to \temp, and you've got a "stuff" directory in there, "cdp -t stuff" will move you over to \temp\stuff. So, whenever more than one path argument is specified, it is treated as relative to what's already been specified (and therefore must not have a leading slash or a drive). The directory stack is kept in a temporary file... DOS: C:/CDP.DAT UNIX: $HOME/.cdpstack which is removed whenever it gets empty. (You can purge the stack at any time by simply deleting this file.) UNIX Note: Whereas the DOS version actually does the directory change, with UNIX we must take a different approach; cdp instead creates a script... $HOME/.cdpscript which must then be sourced by the shell. For example, in .kshrc I have... function cdp { if ~/bin/cdp $* then . ~/.cdpscript fi } POSIX shell prefers something like this (to handle the case of no argument, since it just bombs if you reference an environment variable that hasn't been set)... function cdp { if ~/bin/cdp ${*:-} then . ~/.cdpscript fi } If the script is created successfully, cdp returns 0 and the script is run. If a valid script is not created for any reason, then cdp returns 1 (not very informative, but we just want to know whether to run the script). Examples: cdp /incoming cdp -p \incoming cdp -p a:/incoming cdp -pt cdp -i comp\compilers cdp -pi comp compilers cdp Standard Options ? Short help -? Long help -h Long help -D Enable debug messaging (if compiled with debug messaging (it was)) -p Push current path to stack As stated earlier, other alpha options can be re/defined by environment variables, with names of the form CDPa, with 'a' being the option to be altered. Current definitions, as compiled today and with whatever environment variables set, are... -d Go to c:/dos -i Go to c:/incoming -m Go to c:/misc -t Go to c:/temp