Welcome!

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

SignUp Now!

highlight.bat - does exactly what it says, highlights text. Grep-ish functionality

Jul
278
7
It's easy to hightlight text with sed!

Code:
echo duck duck goose duck duck | sed '/goose/,${s//\x1b[1;33;41m&\x1b[0m/g;b};$q5'

So make a bat file out of it!

Code:
@echo off
sed '/%@UNQUOTE[%*]/,${s//\x1b[1;33;41m&\x1b[0m/g;b};$q5'

Then you can pipe stuff to highlight. So easy to remember! It's great if you get more grep results than you expect, but you still don't want to JUST return the 1 line you're looking for:

1685985877915.png




It's great for highlighting the secondary thing you're looking for in something. Here's my sed version:
1685985792425.png





Storytime below:

I used to do this in a much more complicated way that involved changing the environment variables that control how grep responds, as well as changing the escape character because I spent years not realizing enclosing it in quotes would keep it from escaping. So the actual working BAT file on my hardrive is total madness:

Code:
@echo off

:PUBLISH:
:DESCRIPTION: A way to highlight text.  Basically a grep-like functionality. Great for doing secondary greps on already grepped blocks of text that you *do* want to see. can be done with grep, but we prefer using sed.

    REM call debug "parameters are %*"
    set SEARCHFOR1=%*
    set SEARCHFOR2=%@UNQUOTE[%*]
    :call debug "Searchfor1/2 are '%SEARCHFOR1%' and '%SEARCHFOR1%'"

::::: DEBUGS:
    set DEBUG_HIGHLIGHT=0

::::: DOCUMENTATION ONLY: SUGGESTED EXAMPLE ENVIRONMENT VALUES:
    :set GREP_COLORS_NORMAL=fn=1;33:ln=1;36;44
    :set GREP_COLOR_NORMAL=1;33;42
    :set GREP_COLORS_HILITE=fn=1;34:ln=1;37;44
    :set GREP_COLOR_HILITE=1;41;37


::::: ENVIRONMENT VALIDATION:
    if "%ENVIRONMENT_VALIDATION_HIGHLIGHT_ALREADY%" eq "1" goto :AlreadyValidated
        call validate-environment-variables GREP_COLOR_NORMAL GREP_COLORS_NORMAL GREP_COLOR_HILITE GREP_COLORS_HILITE
        call validate-in-path sed
        set ENVIRONMENT_VALIDATION_HIGHLIGHT_ALREADY=1
    :AlreadyValidated

::::: STORE ORIGINAL GREP-COLOR AND ESCAPE KEY, SWAP OUT FOR HILIGHT-SPECIFIC GREP-COLOR:
    set GREP_COLORS=%GREP_COLORS_HILITE%



::::: DEBUG INFO:
        if %DEBUG_HIGHLIGHT ne 1 goto :No_Debug
            echo SEARCHFOR1=%SEARCHFOR1%
            echo SEARCHFOR2=%SEARCHFOR2%
            echo sed '/%SEARCHFOR1/,${s//\x1b[1;33;41m&\x1b[0m/g;b};$q5'  [with searchfor1]
            echo sed '/%SEARCHFOR2/,${s//\x1b[1;33;41m&\x1b[0m/g;b};$q5'  [with searchfor2]
        :No_Debug

::::: DO THE ACTUAL HIGHLIGHTING:
    call change-escape-character-to-tilde silent

        sed '/%SEARCHFOR2/,${s//\x1b[1;33;41m&\x1b[0m/g;b};$q5'
   
    call change-escape-character-back silent


   

::::: RESTORE ORIGINAL GREP-COLORS AND ESCAPE CHARACTER:
    set  GREP_COLOR=%GREP_COLOR_NORMAL%
    set GREP_COLORS=%GREP_COLORS_NORMAL%


And if you want a simple validate-in-path.bat:

Code:
@echo off
for %arg in (%*) do (
    set search=%@SEARCH[%arg]

    REM echo * search = %search%
    if "%search%" eq "" (

            echo FATAL ERROR! %arg is not in your path, and needs to be.
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
            pause
    )
)
 
Don't you find that things are a little inconsistent? I'm using the same sed as you, and this happens (somewhat randomly).

1685987331167.png
 
mine's inconsistent because of the buginess of windows terminal console, but it's not THAT inconsistent.


I would be super curious if you had the same approximate percentage mis-fires if you added a background color to it. My theory is that if ansi is breaking, having twice as much ansi will mean half the time it breaks the foreground, half the time it breaks the background, but the break will be more apparent that way because you only need 1 of the codes to survive to perceive the end of the highlighting (even if rendered incorrectly).

I think that might not change the inconsistency.

But I think it would by 75% the instances where you can't see where your highlight ends.
 
I don't think it's the console. I watched all 1000 of these in CMD and it never happened.

1685994051411.png
 
Oh, is there a bug in my regex? ANSI does work when things are close enough. And I've also become concerned that potentially malformed ANSI in my prompt could be a confounding variable.

p.s. your test works better with echos instead of echo because you can see more of them at once hahahahaha :D :D :D
 
btw, that test worked flawlessly for me, too. Both with your example and with me substituting in my live highlight.bat.
 
But I know what you mean. I experience it a lot with grep.

Maybe it's more reliable to use sed to grep? oh god, i don't want to think about that
1 sed for the highlight piped to a 2nd sed that somehow uses a conditional regex to exclude lines that don't match what you highlighted would do the trick [i'm not sure how to do that]

i'd love this, if it had fewer ansi errors
 
To be honest, I think the ANSI errors come from TCC (momentarily removing ENABLE_VIRTUAL_TERMINAL_PROCESSING from the console's output mode). I've mentioned it a few times to no avail. I wish I had a smoking gun.
 
I can consistently reproduce it with:

*tasklist /o /l|grep --text --color=always "[0-9][^tc]*opera "|c:\cygwin\bin\cut.exe -c1-%@EVAL[%_COLUMNS-1]

But could this be blamed on grep? Could this be a grep bug, or a cut bug?

1685996721576.png


1685996640389.png
 
So i would say this is my smoking gun:
A youtube video of me reproducing the bug.
[warning, video has loud music]

 
So, I found this intriguing, and decided to give it a try. Turns out, it didn't work correctly because my GNU utilities were too old (2009). After updating them to the latest, it does work, but for some reason, my grep highlight colour is different than yours; any idea why? But also, with the old versions or the new versions, it does not work with single quotes, as yours does, but only when I change the single quotes to double quotes, either on the command line, or in the batch file.

Anyway, I wanted to confirm that the issue mentioned by @vefatica is showing up here as well, and rather frequently at that, though it is different every time.

screen.jpg
 
That's really weird about the grep highlight color. I originally just fiddled around randomly until I found a highlight color I wanted, so there wasn't much of a method to it hehe
 
I'm super happy someone else actually tried this out though!

Like, sometimes you want a secondary grep cause your first grep is still too much stuff, but you don't want to ONLY see the secondary grep. I got weird itches that need scratching and I'm glad I'm not the only one.
 
Like, sometimes you want a secondary grep cause your first grep is still too much stuff, but you don't want to ONLY see the secondary grep.
Exactly. And your batch file solves it nicely. Thanks for posting.

Strange that my default colours were different than yours. However, I found in the documentation that one can change the colours with an environment variable, which I've now done, since I find the default dark blue and dark green difficult to read on a black background.
 
Exactly. And your batch file solves it nicely. Thanks for posting.

Strange that my default colours were different than yours. However, I found in the documentation that one can change the colours with an environment variable, which I've now done, since I find the default dark blue and dark green difficult to read on a black background.
Accessibility is important! I'm glad you found a solution!

I have another BAT file that basically defines everything Windows Terminal (a good container for TCC because it can actually display unicode/emoji/advanced ansi) as an environment variable so you can do things like %ANSI_RED %ANSI_BACKGROUND_WHITE %ANSI_BOLD %ANSI_UNDERLINE %ANSI_BLINKING %@ANSI_RGB_FG[255,0,0] and things like that. Makes life easier for me at least.

Code:
rem ANSI: Initialization
        rem set up basic beginning of all ansi codes
            set ESCAPE=%@CHAR[27]
            set ANSI_ESCAPE=%@CHAR[27][
                set ANSIESCAPE=%ANSI_ESCAPE%

rem ANSI: special stuff: reset
            set ANSI_RESET=%ANSI_ESCAPE%0m
                set ANSIRESET=%ANSI_RESET%

rem ANSI: special stuff: position save/restore
            set ANSI_POSITION_SAVE=%ESCAPE%7%ANSI_ESCAPE%s                  %+ REM we do this the DEC way, then the SCO way
            set ANSI_POSITION_RESTORE=%ESCAPE%8%ANSI_ESCAPE%u               %+ REM we do this the DEC way, then the SCO way
                set ANSI_SAVE_POSITION=%ANSI_POSITION_SAVE%              
                set ANSI_RESTORE_POSITION=%ANSI_POSITION_RESTORE%        
            set ANSI_POSITION_REQUEST=%ANSI_ESCAPE%6n                        %+ REM request cursor position (reports as ESC[#;#R)
                set ANSI_REQUEST_POSITION=%ANSI_POSITION_REQUEST%

rem ANSI: position movement
        rem To Home
            set ANSI_HOME=%ANSI_ESCAPE%H                                    %+ REM moves cursor to home position (0, 0)
                set ANSI_MOVE_HOME=%ANSI_HOME%
                set ANSI_MOVE_TO_HOME=%ANSI_HOME%

        rem To a specific position
            function ANSI_MOVE_TO_POS1=`%@CHAR[27][%1;%2H`                  %+ rem moves cursor to line #, column #\_____ both work
            function ANSI_MOVE_TO_POS2=`%@CHAR[27][%1;%2f`                  %+ rem moves cursor to line #, column #/
                function ANSI_MOVE_POS=`%@CHAR[27][%1;%2H`                  %+ rem alias
                function ANSI_MOVE=`%@CHAR[27][%1;%2H`                      %+ rem alias
            function ANSI_MOVE_TO_COL=`%@CHAR[27][%1G`                        %+ rem moves cursor to column #
            function ANSI_MOVE_TO_ROW=`%@CHAR[27][%1H`                      %+ rem unfortunately does not preserve column position! not possible! cursor request ansi code return value cannot be captured

        rem Up/Down/Left/Right
            set ANSI_MOVE_UP_1=%ESCAPE%M                                    %+ rem moves cursor one line up, scrolling if needed
                set ANSI_MOVE_UP_ONE=%ANSI_MOVE_UP_1%                       %+ rem alias
            function ANSI_MOVE_UP=`%@CHAR[27][%1A`                            %+ rem moves cursor up # lines
                function ANSI_UP=`%@CHAR[27][%1A`                            %+ rem alias
            function ANSI_MOVE_DOWN=`%@CHAR[27][%1B`                        %+ rem moves cursor down # lines
                function ANSI_DOWN=`%@CHAR[27][%1B`                            %+ rem alias
            function ANSI_MOVE_RIGHT=`%@CHAR[27][%1C`                        %+ rem moves cursor right # columns
                function ANSI_RIGHT=`%@CHAR[27][%1C`                        %+ rem alias
            function ANSI_MOVE_LEFT=`%@CHAR[27][%1D`                        %+ rem moves cursor left # columns
                function ANSI_LEFT=`%@CHAR[27][%1D`                            %+ rem alias

        rem Line-based
            function ANSI_MOVE_LINES_DOWN=`%@CHAR[27][%1E`                  %+ rem moves cursor to beginning of next line, # lines down
            function ANSI_MOVE_LINES_UP=`%@CHAR[27][%1F`                    %+ rem moves cursor to beginning of previous line, # lines up




rem ANIS: colors
        rem custom rgb colors
             set ANSI_RGB_PREFIX=%ANSI_ESCAPE%38;2;
             set ANSI_RGB_SUFFIX=m
             function ANSI_RGB=`%@CHAR[27][38;2;%1;%2;%3m`
                 function ANSI_FG=`%@CHAR[27][38;2;%1;%2;%3m`               %+ rem alias
                 function ANSI_RGB_FG=`%@CHAR[27][38;2;%1;%2;%3m`           %+ rem alias
                 function ANSI_FG_RGB=`%@CHAR[27][38;2;%1;%2;%3m`           %+ rem alias
             function ANSI_RGB_BG=`%@CHAR[27][48;2;%1;%2;%3m`             
                 function ANSI_BG=`%@CHAR[27][48;2;%1;%2;%3m`               %+ rem alias
                 function ANSI_BG_RGB=`%@CHAR[27][48;2;%1;%2;%3m`           %+ rem alias

        rem Foreground Colors
            set ANSI_BLACK=%ANSI_ESCAPE%30m
            set ANSI_RED=%ANSI_ESCAPE%31m
            set ANSI_GREEN=%ANSI_ESCAPE%32m
            set ANSI_YELLOW=%ANSI_ESCAPE%33m
            set ANSI_BLUE=%ANSI_ESCAPE%34m
            set ANSI_MAGENTA=%ANSI_ESCAPE%35m
            set ANSI_CYAN=%ANSI_ESCAPE%36m
            set ANSI_WHITE=%ANSI_ESCAPE%37m
            set ANSI_GRAY=%ANSI_ESCAPE%90m
            set ANSI_GREY=%ANSI_ESCAPE%90m
            set ANSI_BRIGHT_RED=%ANSI_ESCAPE%91m
            set ANSI_BRIGHT_GREEN=%ANSI_ESCAPE%92m
            set ANSI_BRIGHT_YELLOW=%ANSI_ESCAPE%93m
            set ANSI_BRIGHT_BLUE=%ANSI_ESCAPE%94m
            set ANSI_BRIGHT_MAGENTA=%ANSI_ESCAPE%95m
            set ANSI_BRIGHT_CYAN=%ANSI_ESCAPE%96m
            set ANSI_BRIGHT_WHITE=%ANSI_ESCAPE%97m
        rem Background Colors
            set ANSI_BLACKGROUND_BLACK=%@ANSI_BG[0,0,0]
            set ANSI_BACKGROUND_BLACK_NON_EXPERIMENTAL=%ANSI_ESCAPE%40m
            set ANSI_BACKGROUND_RED=%ANSI_ESCAPE%41m
            set ANSI_BACKGROUND_GREEN=%ANSI_ESCAPE%42m
            set ANSI_BACKGROUND_YELLOW=%ANSI_ESCAPE%43m
            set ANSI_BACKGROUND_BLUE=%ANSI_ESCAPE%44m
            set ANSI_BACKGROUND_MAGENTA=%ANSI_ESCAPE%45m
            set ANSI_BACKGROUND_CYAN=%ANSI_ESCAPE%46m
            set ANSI_BACKGROUND_WHITE=%ANSI_ESCAPE%47m
            set ANSI_BACKGROUND_GREY=%ANSI_ESCAPE%100m
            set ANSI_BACKGROUND_GRAY=%ANSI_ESCAPE%100m
            set ANSI_BACKGROUND_BRIGHT_RED=%ANSI_ESCAPE%101m
            set ANSI_BACKGROUND_BRIGHT_GREEN=%ANSI_ESCAPE%102m
            set ANSI_BACKGROUND_BRIGHT_YELLOW=%ANSI_ESCAPE%103m
            set ANSI_BACKGROUND_BRIGHT_BLUE=%ANSI_ESCAPE%104m
            set ANSI_BACKGROUND_BRIGHT_MAGENTA=%ANSI_ESCAPE%105m
            set ANSI_BACKGROUND_BRIGHT_CYAN=%ANSI_ESCAPE%106m
            set ANSI_BACKGROUND_BRIGHT_WHITE=%ANSI_ESCAPE%107m


REM As of Windows Terminal we can now actually display italic characters
            REM 0m=reset, 1m=bold, 2m=faint, 3m=italic, 4m=underline, 5m=blink slow, 6m=blink fast, 7m=reverse, 8m=conceal, 9m=strikethrough
            set ANSI_BOLD=%ANSI_ESCAPE%1m
            set ANSI_BOLD_ON=%ANSI_BOLD%
            set ANSI_BOLD_OFF=%ANSI_ESCAPE%22m
            set      BOLD_ON=%ANSI_BOLD_ON%
            set      BOLD_OFF=%ANSI_BOLD_OFF%
            set      BOLD=%BOLD_ON%

            set ANSI_FAINT=%ANSI_ESCAPE%2m
            set ANSI_FAINT_ON=%ANSI_FAINT%
            set ANSI_FAINT_OFF=%ANSI_ESCAPE%22m
            set      FAINT_ON=%ANSI_FAINT_ON%
            set      FAINT_OFF=%ANSI_FAINT_OFF%
            set      FAINT=%FAINT_ON%

            set ANSI_ITALICS=%ANSI_ESCAPE%3m
            set ANSI_ITALICS_ON=%ANSI_ITALICS%
            set ANSI_ITALICS_OFF=%ANSI_ESCAPE%23m
            set      ITALICS_ON=%ANSI_ITALICS_ON%
            set      ITALICS_OFF=%ANSI_ITALICS_OFF%
            set      ITALICS=%ITALICS_ON%

            set ANSI_UNDERLINE=%ANSI_ESCAPE%4m
            set ANSI_UNDERLINE_ON=%ANSI_UNDERLINE%
            set ANSI_UNDERLINE_OFF=%ANSI_ESCAPE%24m
            set      UNDERLINE_ON=%ANSI_UNDERLINE_ON%
            set      UNDERLINE_OFF=%ANSI_UNDERLINE_OFF%
            set      UNDERLINE=%UNDERLINE_ON%

            set ANSI_OVERLINE=%ANSI_ESCAPE%53m
            set ANSI_OVERLINE_ON=%ANSI_OVERLINE%
            set ANSI_OVERLINE_OFF=%ANSI_ESCAPE%55m
            set      OVERLINE_ON=%ANSI_OVERLINE_ON%
            set      OVERLINE_OFF=%ANSI_OVERLINE_OFF%
            set      OVERLINE=%OVERLINE_ON%

            set ANSI_DOUBLE_UNDERLINE=%ANSI_ESCAPE%21m
            set ANSI_DOUBLE_UNDERLINE_ON=%ANSI_DOUBLE_UNDERLINE%
            set ANSI_DOUBLE_UNDERLINE_OFF=%ANSI_ESCAPE%24m
            set      DOUBLE_UNDERLINE_ON=%ANSI_DOUBLE_UNDERLINE_ON%
            set      DOUBLE_UNDERLINE_OFF=%ANSI_DOUBLE_UNDERLINE_OFF%
            set      DOUBLE_UNDERLINE=%DOUBLE_UNDERLINE_ON%

                set ANSI_UNDERLINE_DOUBLE=%ANSI_DOUBLE_UNDERLINE%
                set ANSI_UNDERLINE_DOUBLE_ON=%ANSI_DOUBLE_UNDERLINE_ON%
                set ANSI_UNDERLINE_DOUBLE_OFF=%ANSI_DOUBLE_UNDERLINE_OFF%
                set      UNDERLINE_DOUBLE_ON=%DOUBLE_UNDERLINE_ON%
                set      UNDERLINE_DOUBLE_OFF=%DOUBLE_UNDERLINE_OFF%
                set      UNDERLINE_DOUBLE=%DOUBLE_UNDERLINE%


            set ANSI_BLINK_SLOW=%ANSI_ESCAPE%5m
            set ANSI_BLINK_SLOW_ON=%ANSI_BLINK_SLOW%
            set ANSI_BLINK_SLOW_OFF=%ANSI_ESCAPE%25m
            set      BLINK_SLOW_ON=%ANSI_BLINK_SLOW_ON%
            set      BLINK_SLOW_OFF=%ANSI_BLINK_SLOW_OFF%
            set      BLINK_SLOW=%BLINK_SLOW_ON%

            set ANSI_BLINK_FAST=%ANSI_ESCAPE%6m
            set ANSI_BLINK_FAST_ON=%ANSI_BLINK_FAST%
            set ANSI_BLINK_FAST_OFF=%ANSI_ESCAPE%25m
            set      BLINK_FAST_ON=%ANSI_BLINK_FAST_ON%
            set      BLINK_FAST_OFF=%ANSI_BLINK_FAST_OFF%
            set      BLINK_FAST=%BLINK_FAST_ON%

            set ANSI_BLINK=%ANSI_BLINK_FAST%
            set ANSI_BLINK_ON=%ANSI_BLINK_FAST_ON%
            set ANSI_BLINK_OFF=%ANSI_BLINK_FAST_OFF%
            set      BLINK_ON=%ANSI_BLINK_ON%
            set      BLINK_OFF=%ANSI_BLINK_OFF%
            set      BLINK=%BLINK_ON%

            set ANSI_REVERSE=%ANSI_ESCAPE%7m
            set ANSI_REVERSE_ON=%ANSI_REVERSE%
            set ANSI_REVERSE_OFF=%ANSI_ESCAPE%27m
            set      REVERSE_ON=%ANSI_REVERSE_ON%
            set      REVERSE_OFF=%ANSI_REVERSE_OFF%
            set      REVERSE=%REVERSE_ON%

            set ANSI_CONCEAL=%ANSI_ESCAPE%8m
            set ANSI_CONCEAL_ON=%ANSI_CONCEAL%
            set ANSI_CONCEAL_OFF=%ANSI_ESCAPE%28m
            set      CONCEAL_ON=%ANSI_CONCEAL_ON%
            set      CONCEAL_OFF=%ANSI_CONCEAL_OFF%
            set      CONCEAL=%CONCEAL_ON%

            set ANSI_STRIKETHROUGH=%ANSI_ESCAPE%9m
            set ANSI_STRIKETHROUGH_ON=%ANSI_STRIKETHROUGH%
            set ANSI_STRIKETHROUGH_OFF=%ANSI_ESCAPE%29m
            set      STRIKETHROUGH_ON=%ANSI_STRIKETHROUGH_ON%
            set      STRIKETHROUGH_OFF=%ANSI_STRIKETHROUGH_OFF%
            set      STRIKETHROUGH=%STRIKETHROUGH_ON%
                set OVERSTRIKE_ON=%STRIKETHROUGH_ON%
                set OVERSTRIKE_OFF=%STRIKETHROUGH_OFF%
                set OVERSTRIKE=%OVERSTRIKE_ON%


REM wow it even supports the vt100 2-line-tall text!
            set BIG_TEXT_LINE_1=%ESCAPE%#3
            set BIG_TEXT_LINE_2=%ESCAPE%#4
            set WIDE=%ESCAPE%#6
                set WIDE_ON=%WIDE%
                set WIDELINE=%WIDE%
                set WIDE_LINE=%WIDE%
                set WIDE_OFF=%ESCAPE%#5
            set BIG_TOP=%BIG_TEXT_LINE_1%
            set BIG_TOP_ON=%BIG_TOP%
            set BIG_BOT=%BIG_TEXT_LINE_2%
            set BIG_BOT_ON=%BIG_BOT%
            set BIG_BOTTOM=%BIG_BOT%
            set BIG_BOTTOM_ON=%BIG_BOTTOM%
            REM this is a guess:
            set BIG_TEXT_END=%ESCAPE%#0
            set BIG_OFF=%BIG_TEXT_END%
            set BIG_TOP_OFF=%BIG_OFF%
            set BIG_BOT_OFF=%BIG_OFF%


REM test strings that demonstrate all this ANSI functionality
        set ANSI_TEST_STRING=concealed:'%CONCEAL%conceal%CONCEAL_off%' %ANSI_RED%R%ANSI_ORANGE%O%ANSI_YELLOW%Y%ANSI_GREEN%G%ANSI_CYAN%C%ANSI_BLUE%B%ANSI_MAGENTA%V%ANSI_WHITE% Hello, world. %BOLD%Bold!%BOLD_OFF% %FAINT%Faint%FAINT_OFF% %ITALICS%Italics%ITALIC_OFF% %UNDERLINE%underline%UNDERLINE_OFF% %OVERLINE%overline%OVERLINE_OFF% %DOUBLE_UNDERLINE%double_underline%DOUBLE_UNDERLINE_OFF% %REVERSE%reverse%REVERSE_OFF% %BLINK_SLOW%blink_slow%BLINK_SLOW_OFF% [non-blinking] %BLINK_FAST%blink_fast%BLINK_FAST_OFF% [non-blinking] %blink%blink_default%blink_off% [non-blinking] %STRIKETHROUGH%strikethrough%STRIKETHROUGH_OFF%
        set ANSI_TEST_STRING_2=%BIG_TEXT_LINE_1%big% %ANSI_RESET% Normal One
        set ANSI_TEST_STRING_3=%BIG_TEXT_LINE_2%big% %ANSI_RESET% Normal Two
        set ANSI_TEST_STRING_4=%WIDE_LINE%A wide line!


REM colors for our messaging system
        set COLOR_ADVICE=        color bright magenta on        black  %+ set ANSI_COLOR_ADVICE=%ANSI_RESET%%ANSI_BRIGHT_MAGENTA%%ANSI_BACKGROUND_BLACK%%+
        SET COLOR_ALARM=         color bright white   on        red    %+ set ANSI_COLOR_ALARM=%ANSI_RESET%%ANSI_BRIGHT_WHITE%%ANSI_BACKGROUND_RED%                         %+ set COLOR_ERROR=%COLOR_ALARM% %+ set ANSI_COLOR_ERROR=%ANSI_COLOR_ALARM% %+ set COLOR_FATAL_ERROR=%COLOR_ERROR% %+ SET ANSI_COLOR_FATAL_ERROR=%ANSI_COLOR_ALARM% %+ set COLOR_ERROR_FATAL=%COLOR_FATAL_ERROR% %+ set ANSI_COLOR_ERROR_FATAL=%ANSI_COLOR_FATAL_ERROR%
        SET COLOR_COMPLETION=    color bright white   on        green  %+ set ANSI_COLOR_COMPLETION=%ANSI_RESET%%ANSI_BRIGHT_WHITE%%ANSI_BACKGROUND_GREEN%                  %+ set COLOR_CELEBRATION=%COLOR_COMPLETION%
        SET COLOR_DEBUG=         color        green   on        black  %+ set ANSI_COLOR_DEBUG=%ANSI_RESET%%ANSI_BRIGHT_GREEN%%ANSI_BACKGROUND_BLACK%
        SET COLOR_IMPORTANT=     color bright cyan    on        black  %+ set ANSI_COLOR_IMPORTANT=%ANSI_RESET%%ANSI_BRIGHT_CYAN%%ANSI_BACKGROUND_BLACK%
        SET COLOR_IMPORTANT_LESS=color        cyan    on        black  %+ set ANSI_COLOR_IMPORTANT_LESS=%ANSI_RESET%%ANSI_BRIGHT_RED%%ANSI_BACKGROUND_BLACK%%faint_on%      %+ set COLOR_LESS_IMPORTANT=%COLOR_IMPORTANT_LESS%
        SET COLOR_INPUT=         color bright white   on        black  %+ set ANSI_COLOR_INPUT=%ANSI_RESET%%ANSI_BRIGHT_WHITE%%ANSI_BACKGROUND_BLACK%                       %+ rem  had this set from inception til 2023
        SET COLOR_GREP=          color bright yellow  on        green  %+ set ANSI_COLOR_GREP=%ANSI_RESET%%ANSI_BRIGHT_YELLOW%%ANSI_BACKGROUND_GREEN%                    
        :ET COLOR_LOGGING=       color bright blue    on        black  %+ set ANSI_COLOR_LOGGING=%ANSI_RESET%%ANSI_BRIGHT_BLUE%%ANSI_BACKGROUND_BLACK%                      %+ rem  For logging temp filenames to screen, etc.
        SET COLOR_LOGGING=       COLOR        cyan    on        red    %+ set ANSI_COLOR_LOGGING=%ANSI_RESET%%ANSI_CYAN%%ANSI_BACKGROUND_RED%%OVERSTRIKE_ON%%ITALICS_ON%    %+ rem  For logging temp filenames to screen, etc.
        SET COLOR_NORMAL=        color        white   on        black  %+ set ANSI_COLOR_NORMAL=%ANSI_RESET%
        SET COLOR_PAUSE=         color        cyan    on        black  %+ set ANSI_COLOR_PAUSE=%ANSI_RESET%%ANSI_CYAN%%ANSI_BACKGROUND_BLACK%
        :ET COLOR_PROMPT=        color        yellow  on        black  %+ set ANSI_COLOR_PROMPT=%ANSI_RESET%%ANSI_YELLOW%%ANSI_BACKGROUND_BLACK%                            %+ rem tried changing to bright red on 20230605
        SET COLOR_PROMPT=        color bright red     on        black  %+ set ANSI_COLOR_PROMPT=%ANSI_RESET%%ANSI_BRIGHT_RED%%ANSI_BACKGROUND_BLACK%                      
        set COLOR_REMOVAL=       color bright red     on        black  %+ set ANSI_COLOR_REMOVAL=%ANSI_RESET%%ANSI_BRIGHT_RED%%ANSI_BACKGROUND_BLACK%                     
        SET COLOR_RUN=           color        yellow  on        black  %+ set ANSI_COLOR_RUN=%ANSI_RESET%%ANSI_YELLOW%%ANSI_BACKGROUND_BLACK%                             
        SET COLOR_SUCCESS=       color bright green   on        black  %+ set ANSI_COLOR_SUCCESS=%ANSI_RESET%%ANSI_BRIGHT_GREEN%%ANSI_BACKGROUND_BLACK%                   
        SET COLOR_SUBTLE=        color bright black   on        black  %+ set ANSI_COLOR_SUBTLE=%ANSI_RESET%%ANSI_BRIGHT_BLACK%%ANSI_BACKGROUND_BLACK%                    
        SET COLOR_UNIMPORTANT=   color        blue    on        black  %+ set ANSI_COLOR_UNIMPORTANT=%ANSI_RESET%%ANSI_BLUE%%ANSI_BACKGROUND_BLACK%                       
        :ET COLOR_WARNING=       color bright yellow  on        black  %+ set ANSI_COLOR_WARNING=%ANSI_RESET%%ANSI_BRIGHT_YELLOW%%ANSI_BACKGROUND_BLACK%                    %+ rem from inception 'til 20230529
        SET COLOR_WARNING=       color bright yellow  on        blue   %+ set ANSI_COLOR_WARNING=%ANSI_RESET%%ANSI_BRIGHT_YELLOW%%ANSI_BACKGROUND_BLUE%                     %+ rem 20230529-
        :ET COLOR_WARNING_LESS=  color        yellow  on        black  %+ set ANSI_COLOR_WARNING_LESS=%ANSI_RESET%%ANSI_YELLOW%%ANSI_BACKGROUND_BLACK%                      %+ set COLOR_WARNING_SOFT=%COLOR_WARNING_LESS% %+ REM inception-20230605
        SET COLOR_WARNING_LESS=  color bright yellow  on        black  %+ set ANSI_COLOR_WARNING_LESS=%ANSI_RESET%%ANSI_BRIGHT_YELLOW%%ANSI_BACKGROUND_BLACK%               %+ set COLOR_WARNING_SOFT=%COLOR_WARNING_LESS% %+ REM 2020606-

rem colors for GREP:
        set GREP_COLOR_NORMAL=mt=1;33;42           %+  set GREP_COLOR_HILITE=1;41;37              %+ set GREP_COLOR=%GREP_COLOR_NORMAL%       
        set GREP_COLORS_NORMAL=fn=1;33:ln=1;36;44  %+  set GREP_COLORS_HILITE=fn=1;34:ln=1;37;44  %+ set GREP_COLORS=%GREP_COLOR_NORMAL% %+ REM do NOT change set GREP_COLORS= to be GREP_COLORS_NORMAL, those are the highlight colors actually
        :SET LC-ALL=C
        :^^^^^^^^^^^ LC-ALL=C actually gives an 86% speed grep increase [as of 2015ish on computer Thailog] at the expense of not being able to grep 2-byte-per-char type unicode files but in 20230504 it was decided unicode files are more common and our new computer is faster so this isn't worth it

set COLORS_HAVE_BEEN_SET=1
:AlreadyDone

if "%1" eq "test" (
    echo %ANSI_TEST_STRING%
    echo %ANSI_TEST_STRING_2%
    echo %ANSI_TEST_STRING_3%
    echo %ANSI_TEST_STRING_4%
)



REM unrelated to colors, but nice-to-have variables:
        set QUOTE=%@CHAR[34]
        set TAB=%CHAR[9]
        set NEWLINE=%@CHAR[12]%@CHAR[13]
 
That's an extensive batch file!

Okay, so at the risk of dating myself, I was building/using computers long before the IBM PC and MS-DOS appeared, so have used many different command consoles, including Linux, and DESQview on MS-DOS. But since finding 4DOS (circa 1992)/4NT/TCC, I've used nothing else for the command line on Windows PCs. I've purchased several versions of Take Command, just for TCC. I've never even really used Take Command. Of course I know of Powershell, but haven't use it, either. To be fair, over the years I've gradually drifted from computers for their own sake, to using computers as tools for work, so I don't spend nearly so much time now in the command console.

So following your post, I did some reading up on Windows Terminal. Hmm... interesting, but I'm not quite convinced. Maybe a little prompting as to why one should use Windows Terminal?
 
That's an extensive batch file!

Okay, so at the risk of dating myself, I was building/using computers long before the IBM PC and MS-DOS appeared, so have used many different command consoles, including Linux, and DESQview on MS-DOS. But since finding 4DOS (circa 1992)/4NT/TCC, I've used nothing else for the command line on Windows PCs. I've purchased several versions of Take Command, just for TCC. I've never even really used Take Command. Of course I know of Powershell, but haven't use it, either. To be fair, over the years I've gradually drifted from computers for their own sake, to using computers as tools for work, so I don't spend nearly so much time now in the command console.

So following your post, I did some reading up on Windows Terminal. Hmm... interesting, but I'm not quite convinced. Maybe a little prompting as to why one should use Windows Terminal?

I came for the unicode/emoji filename support because I was sick of black boxes in my filenames, i'm in a situation where i obtain a lot of filenames with emoji and unicode characters in the filename.

I stayed for tabs, panes, amazing ansi support, and just better everything all around.

That being said, I never used TCMD.exe, only TCC.exe, so i never used TCC's own wrapper, and maybe it's better too.


Panes are amazing, but maybe other stuff supports that too. But not having to switch between tasks in a way that destroys as much of my personal attention span helps

1689542134066.png

^ Notice the double-height text ("Answer: 20") - i'm having so much fun with that

But mainly, I got angry at unicode one day and went on a crusade for weeks to purge it from my system, then went on a crusade to ge it fully supported in my workflows, and that's how i ended up running inside a container. Since TCC doesn't actually render it's own characters from what i understand. So this fixes a lot of stuff that just didn't work when running TCC.exe directly


The ways it renders characters are interesting too. It's smart. Like if you do "=>" they actually connect without space between = and > .... all kinds of stuff i've never seen in my similarly-long command line life.
 
That looks real nice; perhaps I'll need to give it a try. :smile:

But 'The quick brown fox jumped over a lazy dog.' doesn't contain an 's'. In telecoms, we used to use 'The quick brown fox jumped over the lazy dog's back.' Or, you could use 'The quick brown fox jumps over a lazy dog.' :rolleyes:
 
@ClioCJS, since you like working with colors, I thought you might like this, WTSCHEME.BTM which uses ANSI to effect the built-in WT color themes.
 

Attachments

But 'The quick brown fox jumped over a lazy dog.' doesn't contain an 's'. In telecoms, we used to use 'The quick brown fox jumped over the lazy dog's back.' Or, you could use 'The quick brown fox jumps over a lazy dog.' :rolleyes:

Waltz, bad nymph, for quick jigs vex!
 
@ClioCJS, since you like working with colors, I thought you might like this, WTSCHEME.BTM which uses ANSI to effect the built-in WT color themes.
Oh wow, it's like colortool.exe but a bat file?!?! Neato!!

[I just wish we could read the current colors prior to setting them.]
 
Back
Top
[FOX] Ultimate Translator
Translate