[comp.os.vms] Need help with the DCL prompt

seeley@dalcsug.UUCP (Geoff Seeley) (03/26/88)

Here is a question for the VMS wizards out there.

I have screwed around with the SET PROMPT= command, but I cannot get
the DCL prompt to reflect the current working directory.
For example, if I was in the directory DISK1:[CSAM2350.CSAM0004],
I want the prompt to be 'CSAM0004 >". If I pop back up a level to
DISK1:[CSAM2350], I would like the prompt to switch to 'CSAM2350 >'
Any ideas out there?  I'm sure that someone out there has done this.


PLEASE SEND REPLYS TO       seeley@dalcsug.UUCP
	OR                  csam0004@dal1


					Thanks in advance,
					Geoff Seeley
-- 
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\  \ Mail replies, questions, | "Oh no ... the brakes don't work! ... Guess     /  / money, women, beer, etc. |       theres no sense in steering now."         \  \           to:            |        -Bob & Doug Mckenzie (STRANGE BREW)      /
/  seeley@dalcsug.uucp     |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\  \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

neubauer@bsu-cs.UUCP (Paul Neubauer) (03/30/88)

In article <412@dalcsug.UUCP> seeley@dalcsug.UUCP (Geoff Seeley) writes:
>I have screwed around with the SET PROMPT= command, but I cannot get
>the DCL prompt to reflect the current working directory.
>For example, if I was in the directory DISK1:[CSAM2350.CSAM0004],
>I want the prompt to be 'CSAM0004 >". If I pop back up a level to
>DISK1:[CSAM2350], I would like the prompt to switch to 'CSAM2350 >'

This topic seems to come up with distressing regularity.  A number of people
have recently posted other command procedures to include directories in a
prompt.  The following DCL routine will (as requested) strip out all but the
most local (i.e. most specific) directory name as the prompt:

$!	PROMPT.COM
$!	Command procedure to set prompt to the current directory.
$!	This procedure removes all of the directory spec EXCEPT for the
$!	most local directory.
$!		Paul Neubauer, Ball State University, 29 March 1988
$!
$ current_dir = f$environment ("default")
$ safe_len = f$length (current_dir)		!prompt never longer than this
$ bracket_loc = f$locate ("[", current_dir)
$ current_dir = f$extract (bracket_loc+1, safe_len, current_dir)
$dot_loop:
$ dot_loc = f$locate (".",current_dir)
$ if dot_loc .eq. f$length (current_dir) then goto no_more_dots
$ current_dir = f$extract (dot_loc+1, safe_len, current_dir)
$ goto dot_loop
$no_more_dots:
$ bracket_loc = f$locate ("]", current_dir)
$ current_dir = f$extract (0, bracket_loc, current_dir)
$ set prompt = "''current_dir'> "

Actually, I do not really use this method.  I prefer and recommend the
following method.  Give each of your directories a logical name (you will
find this EXTREMELY useful for referring to your various directories
anyway).  Then you can use a procedure like the following:

$!	CD.COM -- a command procedure to change directory and set prompt 
$!	to current directory.  
$!	Parameter:  LOGICAL NAME of the destination directory (or null)
$!		Paul Neubauer, Ball State University, 29 March 1988
$!
$! clear			!optional clear screen command use your own 
$ if p1 .eqs. "" then goto main
$ set default 'p1
$ set prompt = "''p1'> "
$ exit
$!
$main:
$ set default sys$login
$ set prompt = "''f$getjpi("","username")'> "
$ exit

Such a CD.COM then provides a general way to change directories and set
prompts.  With a logical name as parameter, you will set your default to
that directory and get the logical name as your prompt.  With no parameter,
you return to your main (login) directory and get your username as prompt.
(Of course, you could have anything else you might want as your prompt too,
e.g. "MAIN> " or "HOME> " or even "$ ".)  My equivalent of this CD.COM does
some additional things for me too, but this is a reasonable skeleton to start
with.

-- 
Paul Neubauer         neubauer@bsu-cs.UUCP
                      <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!neubauer