Call a complex function

Jun 24, 2008
223
0
Siegen, Germany
Nope. The function I'd like to use is too complex for a standard function (it's a Git prompt - like I use it in bash). I'm looking for method to produce a new string before the prompt returns, and PROMPT just spitting out that string. Linux btw. does it by providing a callback hook ($PROMPT_COMMAND). But in TCC I haven't seen anything the like.
 
May 20, 2008
12,171
133
Syracuse, NY, USA
($PROMPT_COMMAND) ... that would seem about the same as
Code:
set prompt=%%@execstr[complicated.BTM]
 
May 20, 2008
12,171
133
Syracuse, NY, USA
You might also try the special alias POST_EXEC. Being an alias, it can have several commands (separated by "&"), or it can execute complicated.btm. In any event, if POST_EXEC creates my_prompt_string and then (lastly) does "SET PROMPT=my_prompt_string", it should work.
 
Jun 24, 2008
223
0
Siegen, Germany
@charles
Wasn't aware that %@execstr[] could call BTM files. However this seems to be slower than using the alias approach (@Rex: could you comment on this?). Also, this approach suffers from the below problem too.

@vince
Unfortunately setting PROMPT in tcstart.btm seems to be treated differently. Setting PROMPT from the command line (e.g. set prompt=%_PID%$s%%git_prompt%%$g$s) works (set PROMPT gives me: <some_pid>$s%git_prompt%$g$s); setting PROMPT in tcstart.btm (same assignment) doesn't work (set PROMPT gives me: <some_pid>$s$g$s), the variable gets eliminated.
I also tried `%...%`, ^%...^%,`%%...%%`, and ^%^%...^%^%, to no avail.
 
May 20, 2008
12,171
133
Syracuse, NY, USA
This should work in both places:
Code:
SET PROMPT=%[_PID]$s%%[git_prompt]$g$s
The value of git_prompt will be an empty string if it isn't defined. If it becomes defined, a non-empty string will appear.
Code:
2244 > type %_tcstart | grep git
SET PROMPT=%[_PID]$s%%[git_prompt]$g$s

2244 > set prompt
2244$s%[git_prompt]$g$s

2244 > set git_prompt=foo

2244 foo>
 
Jun 24, 2008
223
0
Siegen, Germany
@vince
Seems my understandig of %s to reference variables was too CMD-bound. %[...] obviously behaves like ${...} in the bash; wasn't aware of that...

One ugliness remains though: when starting a new TCC session, POST_EXEC is not executed prior to the first prompt. Of course one might argue "No command was executed before this first prompt", and would be correct. It would be nice however, to have the desired information right in the first prompt i.e. w/o having to resort to call the POST_EXEC alias manually once.

@all
Thanks for your help!
 
May 29, 2008
572
4
Groton, CT
This seems to work for me:
Code:
if isalias post_exec post_exec
as the last command of TCSTART.BAT (or .BTM).
 

Similar threads