Shorter prompt / ANSI codes support

Jun 1, 2008
30
0
I'm using TCC on WinXP SP2. My TCC prompt shows the current dir, which often ends up being a very long string (e.g. "C:\Documents and Settings\Someone\My Documents\My Pictures\Category>"). I'm trying to come up with a way to shorten this prompt, by either displaying only the last two tokens of the current path (".../My Pictures/Category>"), or simply truncating everything but the 15 rightmost characters ("...ctures/Category>"). It doesn't seem like the standard prompt syntax allows any string operations on the $p variable which displays the current dir. I'm trying to deal with the problem by using ANSI codes in the prompt definition to shift the cursor left and wipe parts of the prompt. However, it looks like TCC doesn't support a few ANSI codes that would come handy, like ESC n G (move cursor to the nth column without changing row) and ESC 1 K (clear from cursor to the beginning of line; ESC 0 K - clear to the end of line works). Is there any other way of solving this? In case it matters, I'm setting the prompt definition via the AutoRun registry key under Command Processor, though it shouldn't make any difference.
 

rconn

Administrator
Staff member
May 14, 2008
12,345
150
element wrote:

> I'm using TCC on WinXP SP2. My TCC prompt shows the current dir, which
> often ends up being a very long string (e.g. "C:\Documents and
> Settings\Someone\My Documents\My Pictures\Category>"). I'm trying to
> come up with a way to shorten this prompt, by either displaying only the
> last two tokens of the current path (".../My Pictures/Category>"), or
> simply truncating everything but the 15 rightmost characters
> ("...ctures/Category>"). It doesn't seem like the standard prompt syntax
> allows any string operations on $p variable which displays the current
> dir. I'm trying to deal with the problem by using ANSI codes in the
> prompt definition to shift the cursor left and wipe parts of the prompt.
> However, it looks like TCC doesn't support a few ANSI codes that would
> come handy, like ESC n G (move cursor to nth column without changing
> row) and ESC 1 K (clear from cursor to beginning of line; ESC 0 K -
> clear to the end of line works). Is there any other way of solving this?

The PROMPT $w option will display the current directory in a shortened
form. You could also use TITLEPROMPT instead, and put the long string
in the title bar and not on the command line.

Rex Conn
JP Software
 
May 20, 2008
11,400
99
Syracuse, NY, USA
On Wed, 04 Jun 2008 23:05:10 -0500, you wrote:


>It doesn't seem like the standard prompt syntax allows any string operations on $p variable which displays the current dir.

It doesn't, but you can put strings in the prompt, for example,

f:\program files\microsoft network monitor 3.0>

prompt `%_disk:\...%@right[15,%_cwds]$g$s`

F:\...rk Monitor 3.0\>

There's also the metacharacter $w.

F:\...rk Monitor 3.0\> prompt `$w$g$s`

F:\...\Microsoft Network Monitor 3.0>

I don't know about doing it with ANSI escape sequences.
--
- Vince
 
Jun 1, 2008
30
0
prompt `%_disk:\...%@right[15,%_cwds]$g$s`
You could also use TITLEPROMPT instead, and put the long string in the title bar and not on the command line.
Great tips, thanks. I'll go with @right. The single path token that $w gives me may be a tad too short.

One more question. TCC comes with a batch file that sets the registry keys to get a "TCC prompt here" context menu for drives and directories. I'm trying to create a similar key for files, so that TCC would open in the parent dir of the selected file. I want to use @path to chop off the file name, but I'm having trouble with the syntax: "C:\Program Files\TCC\tcc.exe" /k *cdd `"%@path[%L]"` doesn't work.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
element wrote:
...
| I want to use
| @path to chop off the file name, but I'm having trouble with the
| syntax: "C:\Program Files\TCC\tcc.exe" /k *cdd `"%@path[%L]"` doesn't
| work.

Unless you somewhere initialized variable L, the main reason is probably
that you misread the "%1" (quote mark, percent sign, numeral one, quote
mark) due to certain fonts' sloppy glyphs to mean "%l" (quote mark, percent
sign, letter l, quote mark).

Note that the /k does nothing.
--
Steve
 
May 20, 2008
3,515
4
Elkridge, MD, USA
element wrote:
| (paraphrased, combined with responses) I want to have
| a possibly abbreviated version of the current directory
| path in the prompt, different from $w

I use full path in the prompt, but break it into two lines, using the $_
special sequence. With a large enough value for _rows this is a satisfactory
compromise.
--
Steve
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
The biggest problem with your first solution is that it doesn't take into
account what happens when the prompt length is less than 15 characters.
Also, you probably intended to use _CWPS instead of _CWDS. The former
does not include the disk. For example:

[C:\CCViews\mintz_XM\MLF_XM\Vortex\Source\DSP] prompt
`[%_disk:\...%@right[15,%_cwds]]`

[C:\...tex\Source\DSP\] cd \

[C:\...C:\]

So something like this might be better:
prompt `[%@if[%@len[%_cwds] gt
18,%@left[3,%_cwds]...%@right[15,%_cwds],%_cwds]]$s`

This next prompt uses ANSI to colorize the prompt - green for local disks
and red for network shares:
prompt=`%=e[37;%@if[%@remote[%_disk] eq 0,42,41];1m[$P]%=e[33;40;1m$s`

If you replace the $P in the above prompt with $w (or $W) or with the @if
expression above, you'll get a colorized, abbreviated prompt.

-Scott




vefatica <>
06/05/2008 12:47 AM
Please respond to



To
Samintz@ra.rockwell.com
cc

Subject
RE: [Support-t-137] Shorter prompt / ANSI codes support






On Wed, 04 Jun 2008 23:05:10 -0500, you wrote:


Quote:

>It doesn't seem like the standard prompt syntax allows any string
operations on $p variable which displays the current dir.
It doesn't, but you can put strings in the prompt, for example,

f:\program files\microsoft network monitor 3.0>

prompt `%_disk:\...%@right[15,%_cwds]$g$s`

F:\...rk Monitor 3.0\>

There's also the metacharacter $w.

F:\...rk Monitor 3.0\> prompt `$w$g$s`

F:\...\Microsoft Network Monitor 3.0>

I don't know about doing it with ANSI escape sequences.
--
- Vince
 
Jun 1, 2008
30
0
So something like this might be better:
prompt `[%@if[%@len[%_cwds] gt 18,%@left[3,%_cwds]...%@right[15,%_cwds],%_cwds]]$s`
Thanks for the fix. Now it looks better at the root level...
 
Jun 1, 2008
30
0
Unless you somewhere initialized variable L, the main reason is probably
that you misread the "%1" (quote mark, percent sign, numeral one, quote
mark) due to certain fonts' sloppy glyphs to mean "%l" (quote mark, percent
sign, letter l, quote mark).
No, I'm not misreading %L (percent sign, capital "el"). This is the variable used in the "TCC prompt here" registry key which defines the context menu for dirs. The key is set by the tcchere.btm script that comes with TCC. %L seems to contain the path to the item for which the context menu is invoked. This is the value of that registry key:

"C:\Program Files\TCC\tcc.exe" /k *cdd "%L"

It works for dirs and I want to do a similar thing for files. Right now, I've got a workaround that uses an intermediate btm file. My registry key for files is:

"C:\Program Files\TCC\tcc.exe" "path_to_start_file\start_file.btm" "%L"

start_file.btm contains only one line: *cdd "%~p1" , where ~p is a string operator that strips the file name off %1 (%1 is what's passed on to start_file.btm). It works. From the context menu of a file, I can open TCC in the parent dir of that file. However, I'd prefer a more elegant solution, wholly contained in the registry. That's why I'm trying to work out the syntax for stripping the file name off %L right on the command line. I tried various forms of ~p and @path, but without success.

Note that the /k does nothing.
Hm... So why is it used by tcchere.btm (which comes with TCC) to define the registry key for directories (see the first key value above)?
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Try doubling the percents for the Tcc commands.

for example: "C:\Program Files\TCC\tcc.exe" /k *cdd %%@path["%L"]

-Scott

element <> wrote on 06/05/2008 05:19:44 PM:


> Quote:
>
> Unless you somewhere initialized variable L, the main reason is probably


> that you misread the "%1" (quote mark, percent sign, numeral one, quote
> mark) due to certain fonts' sloppy glyphs to mean "%l" (quote mark,
percent

> sign, letter l, quote mark).
>
> No, I'm not misreading %L (percent sign, capital "el"). This is the
> variable used in the "TCC prompt here" registry key which defines
> the context menu for dirs. The key is set by the tcchere.btm script
> that comes with TCC. %L seems to contain the path to the item for
> which the context menu is invoked. This is the value of that registry
key:

>
> "C:\Program Files\TCC\tcc.exe" /k *cdd "%L"
>
> It works for dirs and I want to do a similar thing for files. Right
> now, I've got a workaround that uses an intermediate btm file. My
> registry key for files is:
>
> "C:\Program Files\TCC\tcc.exe" "path_to_start_file\start_file.btm" "%L"
>
> start_file.btm contains only one line: *cdd "%~p1" , where ~p is a
> string operator that strips the file name off %1 (%1 is what's
> passed on to start_file.btm). It works. From the context menu of a
> file, I can open TCC in the parent dir of that file. However, I'd
> prefer a more elegant solution, wholly contained in the registry.
> That's why I'm trying to work out the syntax for stripping the file
> name off %L right on the command line. I tried various forms of ~p
> and @path, but without success.


> Quote:
>
> Note that the /k does nothing.
>
> Hm... So why is it used by tcchere.btm (which comes with TCC) to
> define the registry key for directories (see the first key value above)?
>
>
 
Similar threads
Thread starter Title Forum Replies Date
vefatica ANSI, PROMPT ... ??? Support 1
FreezerBurnt ANSI Prompt messes up list output. Support 39
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
M How to? Black TCC Prompt Support 2
N Command execution slows down in TCC Prompt after a while Support 6
K Fixed Prompt display will be shifted after use dir to display a filename with Chinese. (v25.00.28 x64) Support 18
vefatica Timing commands with $= in the prompt? Support 16
samintz How to? Alias or prompt? Support 1
T Elapsed time format in prompt changed in TCC 25 Support 10
samintz MOVE and Prompt on overwrite Support 3
robinsiebler Creating a custom prompt Support 9
K TCC prompt background color Support 4
Alpengreis Problem if command prompt is not legacy Support 4
Joe Caverly Documentation Customizing the TCC Prompt Support 0
C How to? handle the UAC prompt on computer restarts with Everything Support 3
B when doing SFTP via IFTP to my secure site my users always get the finger print key prompt Support 1
M PROMPT with git branch Support 1
MikeBaas How to? SELECT: exclude files / display prompt Support 2
vefatica ? "prompt" command Support 3
S Elapsed time in TCC prompt question Support 0
Joe Caverly Determine if program started from command prompt Support 2
W Opening a new tab takes forever to get the command prompt Support 5
vefatica UAC prompt? Support 0
C How to? ctrl-c does not prompt "Terminate batch job" Support 2
Mordachai TCMD Prompt Here?!@ Support 14
vefatica Fixed DO, OSD, and cancel batch prompt Support 3
CWBillow Send Command-line with prompt? Support 6
David McClelland Why the prompt to del c:\* Support 7
S WAD BDEBUGGER command changes window title to "TCC Prompt" Support 4
S WAD Invoking BDEBUGGER changes window title to "TCC Prompt" Support 7
vefatica Cancel batch prompt? Support 0
1 CMD file kicks out to prompt Support 18
Steve Pitts Are you sure prompt from DEL command Support 5
Exolon Strange Prompt. Support 6
JohnQSmith TC 13 - Prompt Support 2
S TITLEPROMPT - width x height in prompt? Support 14
T Wrong prompt in Windows command console Support 3
S 4NT - delete from command prompt and recycle bin Support 12
vefatica @@key aliases cause new prompt? Support 16
H Another multiple FTP password prompt issue Support 2
H Double prompt for password with * in FTP syntax Support 3
CWBillow TCMD prompt here only opens to root Support 6
D setting days back at prompt Support 12
M TCC Prompt Here Colors Support 0
Phileosophos Using a percent sign in the PROMPT Support 3
Charles Dye INPUT prompt oddity Support 5
R Start Prompt Here? Support 9
Ville Changing folders location from TCC prompt? Support 7
vefatica ANSI??? Support 9
samintz ANSI issues Support 3

Similar threads