Welcome!

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

SignUp Now!

WAD TITLEPROMPT Not Working

Jun
552
4
Part of my prompt variable includes code for setting the title of the TCC tab in Take Command. It works fine with version 27 but does not work properly in version 30.

My prompt code sets the title to the tail of the current directory. When I change to a new directory (cd newdir), the title does not update. If I press ENTER, forcing a new prompt, the title does then update. However, I have verified that the value of the titleprompt variable has changed correctly even when the title displayed has not changed.

Has something purposely changed with the way the TITLEPROMPT variable works?
 
OK. Here's a simplified version that illustrates the problem. Here's the value of the prompt variable:

C:\temp>set prompt $P$g%@exec[@*set titleprompt=%_cwd]

And here are some images showing how it does not work correctly. I'm in folder c:\temp with the tab title correct and have entered, but not executed, the command to change to the Dropbox folder.

1686291984791.png


Now I press ENTER to execute the command. That puts me in the Dropbox folder, but the tab title did not change.

1686292031581.png


Now I press ENTER to refresh the prompt:

1686292076335.png


Now the title has updated. In version 27, the title updates immediately when I change to a new folder. I don't have to press ENTER an extra time.

This misbehavior is a problem because I use the tab title to identify which TCC session is working in which folder.
 
Yup. set prompt=`$P$g%@exec[@*set titleprompt=%_cwd]` works as you might want it to in v27 and not in v30.

I'm curious, Jay. What's the unsimplified version? Why not just $P for TITLEPROMPT? What can't you do in TITLEPROMPT itself? My TITLEPROMPT looks like this.

Code:
titleprompt=$s%[_4ver].%[_build]$s$s[%_pid]$s$s$p
 
Because some paths are long and I limit my tab title widths (so that I can see a number of them), in my actual prompt I trim the path to just the rightmost characters that will fit.

Here's my real prompt. If you have any suggestions to improve it, I'd be happy to hear them. I must at one time have fiddled quite a bit to get it to work, and I have not revisited it. It works.

TCC(30.00.18): C:\>set prompt
TCC(%_4ver.%_build): $P$g%@exec[@*set titleprompt=%@format[%tabsize2,%@if[%@right[1,%_cwd] EQ \,%_cwd,%@right[%tabsize2,%_cwd]]]]

I have a variable "tabsize" that I set to the tab-width value I set in the Take Command options. (I wish there were a system variable to get that value so that the prompt setting could be automatic. The variable "tabsize2" is computed from "tabsize" to allow for space required for other things in the title. The value of "tabsize2" used to be 8 less than "tabsize", but I just realized that I can turn off icons in the tab title, so now I'm using "tabsize - 4". I never run anything other than TCC in Take Command, so I don't need the icon.

Now that you asked about this, I did look at the prompt again, and I don't understand why I have the @IF test in there. I vaguely recall that something special was required at one time for the root directory, but the simpler setting below seems to work just fine now.

TCC(30.00.18): C:\>set prompt
TCC(%_4ver.%_build): $P$g%@exec[@*set titleprompt=%@format[%tabsize2,%@right[%tabsize2,%_cwd]]]
 
Not a v30 issue; the titleprompt handling was changed slightly in v28.

Before I get into the details of the change, what inspired you to use the (slightly deranged?) @exec call? At best, calling @exec is going to cause your tab title to flash as it's written multiple times with different values on each command line.
 
How should I force a recalculation of the titleprompt value after each directory change?

As for flashing, I certainly never see any flashing of the tab title. It works just fine, except that now it doesn't update until the second time the prompt is generated in a given directory.

OK. I think I figured it out. I can use the cd_enter alias.

I came up with that prompt long before TCC supported the cd_entry alias. In fact, the prompt used to be far more complex. It would also check to see if a new directory was being entered. If so, it would see if a file autoex.btm existed and, if so, run it. When cd_enter came along, I pulled that part of the code out of the prompt variable. Now I see that I can equally well pull out the setting of titleprompt. Much cleaner, and it works without the problem I described.
 
How should I force a recalculation of the titleprompt value after each directory change?

You don't need to change the TitlePrompt variable, any more than you need to change the Prompt variable. Just include $p or %_cwd or whatever. It will be expanded every time the prompt is displayed.
 
I do have to recalculate it. The default behavior is to truncate the end of the path, which is the part I want to see. I want to strip off enough at the beginning of the path so that the rest fits in the tab title.

Now that I added

set titleprompt=%@format[%tabsize2,%@right[%tabsize2,%_cwd]]

to my cd_enter alias definition, everything is working very nicely.
 
As I explained in my answer to Rex, I came up the with @EXEC kludge before the cd_enter and cd_leave functions were added to TCC. It was, I have to say, a masterful way to achieve the cd_enter and cd_leave capability with the functionality available at the time. It served me for many years.
 
I generally do not need to see the drive and prefer to see more of the ending directory tree. Where are those $ parameters documented? I see the help topic "Customizing the Prompt", but it does not list them or, as best I see, give a link to a page that does have them.
 
You only needed to use @exec because you were using @exec.

What is happening is that the @exec call ends up expanding the variables in the titleprompt string and then writing that back to the environment as a literal (i.e., the expanded result of %_cwd).

If you set the TITLEPROMPT string w/o @exec, it will be evaluated each time a new prompt is displayed (just like PROMPT is)
 
Thanks. I think I got it now.

I have now given titleprompt a value with the formula.

TCC(30.00.18): C:\>set titleprompt
%@format[%tabsize2,%@right[%tabsize2,%_cwd]]

And I no longer need to include it in cd_enter.
 
I generally do not need to see the drive and prefer to see more of the ending directory tree. Where are those $ parameters documented? I see the help topic "Customizing the Prompt", but it does not list them or, as best I see, give a link to a page that does have them.
1686343908451.png

Joe
 

Similar threads

Back
Top