Big_Papa_B
Big_Papa_B

Reputation: 139

Change prompt in OpenVMS

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?

Upvotes: 3

Views: 1516

Answers (1)

Vince
Vince

Reputation: 21

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.

Upvotes: 1

Related Questions