3

I am looking for some assistance with openVMS.

The default prompt under VMS is $

I want to update this to reflect the current working directory that I am located in as I can in Unix/Linux when I change directories.

I created a file named login.com and put this into my home directory in the openVMS system and added the following code:

$ SET PROMPT='f$environment("default")'

Which should work by displaying the current directory, however it only reflects my home directory at the time of login. It is not dynamically updating as I change directories. If I run the above command in the terminal it will show the current directory.

Is there anyway to update the login.com to dynamically update the prompt each time that I change the directory?

David Hoelzer
  • 15,862
  • 4
  • 48
  • 67
Big_Papa_B
  • 139
  • 1
  • 14
  • You can't make the prompt dynamic, but you can change the way you change directories. Use a command procedure to set the directory and update the prompt. Unfortunately this will not help if existing command procedures or applications alter the current default directory. Have a look at 20 and 21 [here](http://www.cts.wustl.edu/~allen/vms-sdt.html) for ways to manipulate a stack of default directories. You could add `set prompt` to them. Or [this](https://www.mpp.mpg.de/~huber/vmssig/src/COM/DIRSTACK.COM) variation on the theme. – HABO Mar 30 '16 at 15:02
  • HABO there was at long ago a dynamic prompt, with the time displayed (so your prompt was 10:03 at 10:03, and 17:12 at 17:12), I remember. Not sure if it had a relationship with dclcompete http://www.digiater.nl/openvms/freeware/v80/dclcomplete/dclcomplete.readme, so you can definitely make the prompt dynamic – user2915097 Apr 05 '16 at 07:13
  • extract from ftp://www.digiater.nl/openvms/decus/vmslt96b/net96b/files_ftp2_kcl_ac_uk.txt `SSHOOK Example of hooking into system services, to give dynamic prompt` – user2915097 Apr 05 '16 at 07:17
  • read http://www.digiater.nl/openvms/decus/vmslt96a/net96a/sshook.txt – user2915097 Apr 05 '16 at 09:00
  • [See this answer if it can help you](http://stackoverflow.com/questions/130640/is-there-a-reasonable-way-to-implement-a-cd-command-on-vms/223455#223455) – Luc M Jul 25 '16 at 17:20

1 Answers1

1

The best you can do as far as I know is to create a command file to change the directory and set the prompt.

Create a file called CD.COM with the following:

$ set default 'p1'
$ current = f$dir()
$ d_start = f$locate ( "[", current ) + 1
$ d_stop = f$length ( current ) - 2
$ current_dir = f$extract( d_start, d_stop, current )
$ new_prompt = "SERVER::" + current_dir + ">"
$
$loop:
$ if f$length(new_prompt) .ge. 30
$       then
$       d_start = f$locate ( ".", new_prompt ) + 1
$       new_prompt = "SERVER::" + f$extract ( d_start, d_stop, new_prompt )
$       goto loop
$ endif
$ set prompt='new_prompt

You can change the condition in the loop depending on how long you want the prompt to be

Then in your LOGIN.COM file create a logical to point to the directory with the CD.COM file

$ DEFINE /GROUP CD "Disk:[Folder.Containing.COM.File]"

Then use it like this:

CD Disk:[Full.Path.To.Dir]

or

CD [.subdir]

The only time this will not update the prompt correctly is if you use the CD command inside another COM file. It will however still change the directory correctly.

Vince
  • 21
  • 3