Customizing the TCC Prompt

You're probably already familiar with changing the prompt in Microsoft's command shells. As in CMD.EXE and COMMAND.COM, TCC's prompt can be modified with thePROMPT command, or by setting an environment variable named PROMPT. All but one of the PROMPT $-sequences from CMD.EXE are supported in TCC, and there are more than a dozen new ones. (The one difference is $M, which was already in use in TCC when Microsoft added it to CMD. You can get the CMD $M behavior with the TCC @TRUENAME variable function.) See the help file for a complete list.


Since TCC's prompt has several additional capabilities beyond those CMD.EXE offers, you will probably want to change TCC's prompt without affecting CMD.EXE's. This is a good task for the startup batch file, TCSTART.BTM. Put a PROMPT command in TCSTART.BTM, and your desired prompt will be set when TCC starts.


In addition to the traditional $ codes, you can put environment variables, internal variables, and functions in your prompt, and they will be expanded each time the prompt is displayed. To prevent them from being expanded at the time you define the prompt variable, surround the entire value with backquotes:


rem A prompt which uses internal variables and functions:

prompt `$n: %@label[%_disk] %@diskfree[%_disk,mc]M free$_%_cwps $g `


It is possible to “hook” the prompt and execute a command before the prompt is displayed by defining a PRE_INPUT, PRE_EXEC, or POST_EXEC alias:


rem A prompt which counts command lines:

set icmd=0

alias pre_exec=`set icmd=%@inc[%icmd]`

prompt `%icmd $P$g`


If you enable ANSI processing, you can embed ANSI escape sequences in your prompt. (To enable ANSI, open the OPTION dialog, select the Windows tab, and turn on the “ANSI Colors” tick box.) You can change colors within the prompt or even move the cursor around:


rem A prompt which uses ANSI colors:

prompt $e[1;32m$t $e[1;31m$g$e[0m

rem A prompt which uses ANSI positioning and colors:

prompt $e[s$e[1;1H$e[1;37;44m$e[K$P$e[0m$e[u$G


TCC also supports a second custom prompt variable, TITLEPROMPT. The contents of TITLEPROMPT are displayed in the tab's label when TCC is running in a Take Command tab window, or in the console window's title bar when TCC is running in a standalone console session. You can use $ codes, variables and functions, just like in PROMPT. ANSI sequences are not meaningful in the title bar, though.




The TITLEPROMPT variable can be used to display prompt information in the title bar.