Article
· Apr 7, 2017 1m read

"Where am I?" - Adding extra information to the Terminal prompt

If you deal with multiple instances of Caché / Ensemble / HealthShare and sometimes have to work at the Terminal command prompt, did you know that you can easily add extra information to that prompt which may help prevent you running a command on the wrong instance?

The format of the command prompt is controlled by the TerminalPrompt setting in the [Startup] section of the CPF but it is normally manipulated via Portal. The documentation is here.

The default prompt looks like this:

USER>
 
USER>; TerminalPrompt="8,2"

The 2 is what provides the namespace name. Most of the time the 8 adds nothing, but you can see its effect by starting a transaction or two, then ending them:

USER>tstart
 
TL1:USER>tstart
 
TL2:USER>tcommit
 
TL1:USER>tcommit
 
USER>

When working with multiple instances, perhaps across different servers, setting TerminalPrompt="8,1,3,2" may be useful:

Node: TIN, Instance: ENS171
 
TIN:ENS171:USER>
 
TIN:ENS171:USER>; TerminalPrompt="8,1,3,2"

Discussion (3)0
Log in or sign up to continue

And if you want to make your own prompt, you could even use your own Shell routine :

Shell ;
    For {
        Try {
            Write !,$$Prompt()
            Read cmd Write !
            Xecute cmd
        } Catch {
            Write $ZE,!
        }
        If ($ZCVT($G(cmd),"U")="QUIT") Quit
    }
    Quit

Prompt() ;Create your own prompt here !
    New prompt
    Set prompt = $ZDate($H,4)_" - "_$ZTime($P($H,",",2))_" > "
    Quit prompt