Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Unable to get PROMPT to do what I want to do

Aug
2,799
144
I have been using this prompt successfully for many years in TCC.
Code:
E:\...\TCC_Stuff>set prompt
$e[9999E$w$g

This prompt jumps to the bottom of the screen via ANSI ESC[9999E (Cursor Next Line capped at last line),
then displays the current directory,
in a shortened format.

Now, I want to have a prompt that also displays the parent process (the process that started TCC);
Code:
C:\WINDOWS\Explorer.EXE
E:\...\TCC_Stuff>

I could not figure out how to do this using just the PROMPT,
so I did a work-around...
Code:
E:\...\TCC_Stuff>which post_exec
post_exec is an alias : e:\utils\post_exec.btm

C:\WINDOWS\Explorer.EXE
E:\...\TCC_Stuff>type e:\utils\post_exec.btm
@echo off
echo %_parent

The reason I want to display the _parent before each prompt,
when I execute the newshell alias,
I want to know what the parent is.

Code:
R:\>which newshell
newshell is an alias : "%_cmdspec" /i e:\utils\newshell.btm

R:\>type e:\utils\newshell.btm
@echo off
alias post_exec=e:\utils\post_exec.btm
echo %_parent

This works,
but if anyone knows how to do the same thing,
using only the Prompt,
sharing how to do this would be appreciated.

Joe
 
Do you mean like this? You can put almost anything in the prompt.

1775873201152.webp
 
No, I want;
Code:
C:\WINDOWS\Explorer.EXE
R:\>
...and I want to keep my existing prompt,
and just amend it with this ability.

That is,
the prompt must always remain at the bottom of the screen,
as it has been doing for many years now.

My OP explains how I do that.

Joe
 
Vince, thank you for your solution,
works as requested.

Code:
C:\WINDOWS\Explorer.EXE
r:\> set prompt
$e[9999E%@wmi[.,"Select ExecutablePath from Win32_Process where ProcessID=%_ppid"]$_$e[92m$p$g$s$e[0m

C:\WINDOWS\Explorer.EXE
r:\> newshell

TCC  36.00.24 x64   Windows 10 [Version 10.0.19045.7058]
Copyright 2026 JP Software Inc.  All Rights Reserved
Your evaluation period expires in 12 days.
You can buy Take Command, TCC, and CMDebug at https://jpsoft.com

C:\Program Files\JPSoft\TCMD36\tcc.exe
r:\> exit

C:\WINDOWS\Explorer.EXE
r:\>

I no longer need my work around using post_exec.

However, why would _parent not work?

Joe
 
_PARENT works (I didn't know about it) but you have to use brackets; the second below shows what happens without them. If you remove the strong quotes around the whole thing (last one below) the value of _PARENT goes into the prompt instead of the reference to the variable. That'll probably save a few microseconds. If you're doing this in TCSTART.BTM any interactive subshell (that processes TCSTART.BTM) will get it right.

1775914767034.webp
 
Last edited:
Thankyou again, Vince.
Code:
R:\> set prompt
$e[9999E[%_parent]$_$e[92m$P$g$s$e[0m

[C:\WINDOWS\Explorer.EXE]
R:\> newshell

TCC  36.00.24 x64   Windows 10 [Version 10.0.19045.7058]
Copyright 2026 JP Software Inc.  All Rights Reserved
Your evaluation period expires in 12 days.
You can buy Take Command, TCC, and CMDebug at https://jpsoft.com

[C:\Program Files\JPSoft\TCMD36\tcc.exe]
R:\> exit

[C:\WINDOWS\Explorer.EXE]
R:\>

I can live with the [] around the _parent name.

Just tried it from a TCC in Windows Terminal;
Code:
[C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.24.10621.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe]
R:\> newshell

TCC  36.00.24 x64   Windows 10 [Version 10.0.19045.7058]
Copyright 2026 JP Software Inc.  All Rights Reserved
Your evaluation period expires in 12 days.
You can buy Take Command, TCC, and CMDebug at https://jpsoft.com

[C:\Program Files\JPSoft\TCMD36\tcc.exe]
R:\> exit

[C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.24.10621.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe]
R:\>

Looks good.

Joe
 
_PARENT seems to be dynamic, in the sense that it looks up the parent every time it's evaluated (not sure that's needed). If the parent process no longer exists and _PARENT is evaluated when the prompt is shown you'll get an empty string. You probably ought to go with the hard-coded value of _PARENT. But then, interactive subshells should also do it to avoid using an inherited PROMPT variable that's wrong.
 
Does an instance started with EXEC inherit _PARENT and not look up it's own parent when it starts?
 
Back
Top