Welcome!

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

SignUp Now!

Shorter prompt / ANSI codes support

Jun
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.
 
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
 
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
 
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.
 
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
 
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
 
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
[email protected]
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
 
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...
 
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)?
 
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)?
>
>
 
Back
Top
[FOX] Ultimate Translator
Translate