Call a complex function

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#3
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.
 
#7
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.
 
#8
@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.
 
#9
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>
 
#11
@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!