[comp.os.vms] getting current dir in dcl prompt

V2002A@TEMPLEVM.BITNET ("The Radio Gnome") (01/27/88)

Hi,

     The logical thing to do would be:

$TEMP = "show default"
$SET PROMPT = 'TEMP'

..but VMS will only take a string for SET PROMPTs argument
and the string must not have spaces in it.  VMS complains about
"too many parameters" >:-{


    There was/is a similar discussion going on in unix-wizards
where:

set prompt 'pwd' (I think?) seemed to do the trick.

    Has anyone else come up with a solution?

     Andy Wing

XRBEO@VPFVM.BITNET (Bruce O'Neel) (01/28/88)

You need to put " in the symbol for set prompt

$ set prompt="//STEP EXEC PGM="

makes me think I'm on mvs.  I believe that the following will work (Im on ibm
right now, I can't try it)

$ tmp = """//STEP EXEC PGM="""
$ set prompt='tmp'

If the syntax isn't right, the idea is.

bruce <xrbeo@vpfvm> on bitnet

-------

V2002A@TEMPLEVM.BITNET ("The Radio Gnome") (01/29/88)

Hi,

     Thanks for the multitude of responses!  The consensus seems to be:

$TEMP = F$ENVIRONMENT("DEFAULT")
$SET PROMPT = "''TEMP'"
or
$TEMP = F$DIRECTORY()
$SET PROMPT = "''TEMP'>"
or more briefly
$SET PROMPT = "''F$ENVIRONMENT("DEFAULT")>"
etc...

However, none of these retain the correct prompt if the default
is changed.  You must execute the commands all over again.
I have two command procedures from the net, SD.COM and CD.COM, which
I will try when I have time.

    Andy Wing   V2002A%TEMPLEVM.BITNET@CUNYVM.CUNY.EDU


"No matter what happens, you can always find someone who predicted it."


-------

JOE@FHCRCVAX.BITNET (Joe Meadows) (01/29/88)

>     The logical thing to do would be:
>
>$TEMP = "show default"
>$SET PROMPT = 'TEMP'

        Actually, the "logical" thing to do would be:
$ SET PROMPT="''F$ENVIRONMENT("DEFAULT")' $ "

        Or some such mess. But why? I mean, when you're down a few
levels you could have a prompt that fills up a whole line, or several
even.. I could see writing it to a status line if your terminal supports
one (mine doesn't, so I prefer to just remember where I'm at).


        Cheers,
        Joe Meadows     joe@fhcrcvax

-------

jj1h+@ANDREW.CMU.EDU (Joseph Jackson) (01/30/88)

> ..but VMS will only take a string for SET PROMPTs argument
> and the string must not have spaces in it.  VMS complains about
> "too many parameters" >:-{

Not to scream RTFM, but the problem above is a very general DCL
concept:  If you want to pass a parameter which contains spaces or
lowercase characters, you have to put that parameter in quotes:

$ SET PROMPT = "Joe's vax> "

This information can be found with "$ HELP SET PROMPT PARAMETERS".


To make the prompt reflect your default directory, you have to change
the way you set your default, not the way you set your prompt.  One
simple way to accomplish this is by writing a command procedure which
you call every time you want to change where you are.  In addition to
doing the set default command, it also sets your prompt.  For example:

$! Jump.com
$!
$ Set default 'P1'
$ Set prompt = "Your at: ''F$environment("DEFAULT")'> "
$ Exit

Of course, some shorter extraction of the string returned by
F$environment may well be more appropriate.  You can learn how to use
F$extract and F$locate to do this with "$ HELP LEXICAL".  Another
handy trick is to put ['P1'] in place of 'P1' in the above procedure
so that you no longer have to enter the brackets yourself.  After
doing this, you only need to say "$ @JUMP .SUBDIR.SUBSUBDIR".  To make
the procedure more convenient to invoke, you could add a line to your
LOGIN.COM similar to:

"$ JUMP :== @dev:[directory]JUMP.COM "
Well, this should give you a rough idea of one technique.
I hope it helps!


Joe.  ;-)


      __________________________________________________________
     |                                                          |
     |                  Joseph L. Jackson, Jr.                  |
     |                Carnegie-Mellon University                |
     |                                                          |
     |        Overland:                   Network:              |
     |  4705 Fifth Ave, Apt.#4M     JJ1h+@andrew.cmu.edu        |
     |  Pittsburgh, PA 15213-2937   Jackson@laurel.psy.cmu.edu  |
     |  (412) 268-5540              Jackson@skidmore.bitnet     |
     |__________________________________________________________|

sommar@enea.se (Erland Sommarskog) (01/31/88)

(Tried to mail, but letter bounced)

>Hi,
>
>     The logical thing to do would be:
>
>$TEMP = "show default"
>$SET PROMPT = 'TEMP'

Wouldn't it be more simple to do just
   SET PROMPT = "SHOW DEFAULT"
That would give the expected result :-)

>    There was/is a similar discussion going on in unix-wizards
>where:
>
>set prompt 'pwd' (I think?) seemed to do the trick.

I don't know if this makes Unix to recalculate the prompt
everytime, but a such a thing is not available in VMS. The
prompt is only changed on demand.

>    Has anyone else come up with a solution?

Try this one. You use it instead of SET DEFAULT. As prompt you get
the name of the current directory, the parent directories are
excluded.
$ Set def 'p1'
$ curr_dir = f$dir() 
$ curr_dir = f$extract(1, f$length(curr_dir)-2, curr_dir) + "> "
$ i = 0
$loop:
$ subdir = f$element(i, ".", curr_dir)
$ i = i + 1
$ if f$locate(">", subdir) .eq. f$length(subdir) then $ goto loop
$ set prompt="''subdir'"
-- 
Erland Sommarskog       
ENEA Data, Stockholm        "Will you remember president Reagan
sommar@enea.UUCP             will you rememeber all the bills we'll have to pay
                             or even yesterday, tomorrow?" - David Bowie

hydrovax@nmtsun.nmt.edu (M. Warner Losh) (01/31/88)

In article <8801281127.AA17941@ucbvax.Berkeley.EDU>, V2002A@TEMPLEVM.BITNET ("The Radio Gnome") writes:
> $TEMP = "show default"
TEMP doesn't get set to the current default.  It gets set to "SHOW DEFAULT"
which explains ....
> $SET PROMPT = 'TEMP'
This expands out to "SET PROMPT = SHOW DEFUALT" which gives the following
behavior:
> 
> ..but VMS will only take a string for SET PROMPTs argument
> and the string must not have spaces in it.  VMS complains about
> "too many parameters" >:-{
> 
try :
   $ TEMP = F$ENVRIONMENT("DEFAULT")
   $ SET PROMPT="'TEMP'"
and this will do the trick.

If you are currently in USER:[WARNER], then your prompt will be set
to USER:[WARNER].

-- 
bitnet:	losh@nmt.csnet			M. Warner Losh
	warner@hydrovax.nmt.csnet    ! Don't know if this works, let me know.
csnet:	warner@hydrovax.nmt.edu
uucp:	...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!warner%hydrovax

dave@wsccs.UUCP (VAX Headroom @ The End of the Galaxy) (02/18/88)

We put the following in sys$manager:cd.com


$ SET DEFAULT 'P1
$ SET PROMPT="''F$DIRECTORY()'> "
$ WRITE SYS$OUTPUT "''F$ENVIRONMENT("DEFAULT")'"
$ EXIT

Then we defined cd in sys$manager:sylogin.com like so,:
cd:==@sys$manager:cd

Then the users who wanted their prompt changed just typed
cd newdirectory-specification.

Note:  This takes no time whatsoever (on our microvax) since
set default, set prompt, and write are all built into dcl and
do not require an image load.

I don't happen to use this and its ancient on our system; I have some ideas
to IMPROVE it greatly that I will get around to sometime.


+-----------------------------------------------------------------------------+ 
|		    |	     Dave E Martin       | DISCLAIMER: Been Cancelled |
|    /\		    | "...between the streets of | $ opinion/mine/noUinTech   |
|   /  \  .    /\   | Dallas, and the beaches of |----------------------------|
|  /    \/ \/\/  \  | Miami ...  THIS  was   Max | ...!ihnp4!utah-cs!utah-gr! |
| / U i n T e c h \ | Headroom's  finest  hour." | uplherc!sp7040!obie!       |
|		    |	          --Max Headroom | wsccs!net23.dnet!dave      |
+-----------------------------------------------------------------------------+

terry@wsccs.UUCP (terry) (02/26/88)

In article <161@wsccs.UUCP>, dave@wsccs.UUCP (VAX Headroom @ The End of the Galaxy) writes:
> 
> We put the following in sys$manager:cd.com
[how to do it deleted]
> Then the users who wanted their prompt changed just typed
> cd newdirectory-specification.
> do not require an image load.

	Credit where credit is due, guy.  I think you removed my comments at
the top of the thing... :-(.


| Terry Lambert           UUCP: ...!decvax!utah-cs!century!terry              |
| @ Century Software       or : ...utah-cs!uplherc!sp7040!obie!wsccs!terry    |
| SLC, Utah                                                                   |
|                   These opinions are not my companies, but if you find them |
|                   useful, send a $20.00 donation to Brisbane Australia...   |
| 'There are monkey boys in the facility.  Do not be alarmed; you are secure' |