From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 10-APR-1991 20:11:58.29
To:	ARISIA::EVERHART
CC:	
Subj:	Re: Set Def Dir & Prompt

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.97)
	 id AA19275; Wed, 10 Apr 91 19:14:29 EDT
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Wed, 10 APR 91 14:16:59 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA14363; Wed, 10 Apr 91 14:06:26 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 10 Apr 91 21:01:20 GMT
From: agate!bionet!uwm.edu!rpi!crdgw1!emsun1.crd.ge.com@ucbvax.Berkeley.EDU  (john f berkery)
Organization: General Electric Corporate R&D Center
Subject: Re: Set Def Dir & Prompt
Message-Id: <18427@crdgw1.crd.ge.com>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

$!---------------------------- cut here --------------------------------------
$! Here's yet another little ditty to reset your default directory. It will not
$! allow you to set default into a non-existant sub-dir and it will also reset
$! the VAX system prompt to whatever subdirectory you go to. No delays, no need
$! for an extra return.
$! 
$! Set up a command alias like "cd :== @cd.com" and then use it like a Unix cd
$! command, but with dots, not with those friggin' slashes. And since the VMS
$! file system is not like Unix, it only works within one directory tree at a
$! time, not across the whole file structure.
$! 
$!  valid cd cmds
$!    cd                  (puts you back to login default dir)
$!    cd .                (won't do much of anything, just like Unix)
$!    cd ..               (puts you up one level in the dir tree)
$!    cd sub-dir          (puts you into the subdir below your present level)
$!    cd sub1.sub2.subn   (puts you a few subdirs farther down)
$!----------------------------------------------------------------------------
$ set noverify
$! CD.COM
$! VAX/VMS DCL command procedure to reset the default directory of the
$! current process to a subdirectory.
$! Jack Berkery, GE Corporate Research & Development, Schenectady NY
$!----------------------------------------------------------------------------
$!     a "cd" command without parameter means return to login directory
$      if p1 .eqs. "" then goto home
$!     "cd ." means stay right here, bogus but that's the way unix works
$      if p1 .eqs. "." then goto sho_def
$!     "cd .." means go back up one level in the directory tree
$      if p1 .eqs. ".." then goto up_one
$!     otherwise go reset the default directory to what was specified
$      save_dir = f$environment("default")
$      goto reset_dir
$!----------------------------------------------------------------------------
$! click your heels 3 times and say, there's no place like home...
$  home:
$      set default sys$login
$      goto sho_def
$!----------------------------------------------------------------------------
$! yo, back up just a bit here dude.
$  up_one:
$      set default [-]
$      goto sho_def
$!----------------------------------------------------------------------------
$! ok lets try to do this reset default thing, hocus, pocus...
$  reset_dir:
$      set default [.'p1']
$!     if a bogus location is specified it will get your wrist slapped
$      on error then goto no_such_dir
$      dir/nooutput
$!     if we've got no trouble in river city, we're on our way
$      goto sho_def
$!----------------------------------------------------------------------------
$! aw shit, bogus input, go right back where you started, do not pass go...
$  no_such_dir:
$      set default 'save_dir'
$      goto sho_def
$!----------------------------------------------------------------------------
$  sho_def:
$!     now, these next several lines will set the prompt to the dir name.
$!     max prompt size is 32, so some front-end chars may be stripped
$      string = f$environment("default")
$      len = f$length(string)
$      offset = len - 30
$      if offset .lt. 0 then offset = 0
$      string = f$extract ( offset, 30, string )
$      set prompt = 'string >> '
$!----------------------------------------------------------------------------
$!     echo the directory we are in when all the shootin's done
$      show default

