OS/2 eZine - http://www.os2ezine.com
Spacer
February 16, 2002
 
James Cannon actively served 12 years in the U.S. Army with a broad range of experience from programming COBOL on a mainframe, to networking simulators with UNIX, and supervising a small IT shop. He continues military service in the U.S. Army Reserve. He is currently working for Agilent Technologies as a "Technical Lead" overseeing the backup operations of 5000+ HP-UX and Windows clients. He is happily married, a proud father, and never gets enough keyboard and mouse time with OS/2 Warp.

If you have a comment about the content of this article, please feel free to vent in the OS/2 eZine discussion forums.

There is also a Printer Friendly version of this page.



Spacer
Previous Article
Home
Next Article


Norman Virus Control version 5 is now available for OS/2 users


Mine tastes like purple...

One of many things stuck in my head are a lot of TV commercials. Everyone seems to remember the "Mikey" commercials. One of my favorites is several kids eating yogurt, or was it ice cream? Anyways, each of the kids are describing the flavor of theirs ... "Mine tastes like Ba nan na!". The most memorable to me was the one kid that said, "Mine tastes like purple." Yeah, I know I'm getting off track here, but I'm getting to a point. Colors are a cool thing, look at the come back of Apple Computer. One thing I do like about using Windows NT 4.0, is the power to change the look and feel of the "console window" with color. All right, I know this is an OS/2 publication.


One method to get color to your OS/2 Command Window (or Full Screen) is to modify the CONFIG.SYS file using:

ANSI ON
SET PROMPT ...

But that still limits you to one color, the one you pick. A lot of the power of OS/2 lies in the Properties of an object. Namely, the OS/2 Command Window and OS/2 Full Screen object. One of the preferred methods to modify an OS/2 Command Session, is to use it in conjunction with a command file (.CMD extension). When first accessing the Properties of the OS/2 Command Session, go to the "Progam" tab, if it is not there already. Look for the "Optional" section and specifically, the "Parameters" subsection.

By using "/k" in the "Parameters" subsection, one can pass command files to modify the OS/2 Command Session. First start out by creating a number of .CMD files that are in your PATH= in your CONFIG.SYS file. I put mine in C:\OS2, where CMD.EXE exists. For example, I have BLUE.CMD, CYAN.CMD, GREEN.CMD, MAGENTA.CMD, RED.CMD, and YELLOW.CMD in my C:\OS2 directory. Following are some of my command files:

GREEN.CMD
@ANSI ON
@PROMPT $e[32;40m$i[$p$g]

YELLOW.CMD
@ANSI ON
@PROMPT $e[33;40m$i[$p$g]

BLUE.CMD
@ANSI ON
@PROMPT $e[34;40m$i[$p$g]

CYAN.CMD
@ANSI ON
@PROMPT $e[36;40m$i[$p$g]

The basic format for all these files are quite similiar. First ANSI is turned on (using the "@" character hides display of the command, but not the output of it.) Next, we start the prompt sequence. The $e begins use of ANSI escape sequences, starting with [ then we have our color combos. I always put foreground first, 31 for red, 32 for green, and so on. 40 sets the background for black. If you want a different color for the background, just add ten to the foreground; ie 32 + 10 = 42 for a green background). I'm not sure about m$i, but going to the prompt $p$g requires a [ preceding it. Finally, it is ended with ]. For colors needing a brightness intensity, These follow below:

MAGENTA.CMD
@ANSI ON
@PROMPT $e[0;35;1m$i[$p$g]

RED.CMD
@ANSI ON
@PROMPT $e[0;31;1m$i[$p$g]

After the $e[, the ANSI sequence is reset to white on black with 0. Then we add or color (35=magenta, 31=red). This is followed by a 1 for brightness. Once all of your command files are set, you can add it to you Properties using "/k" in the "Parameters" subsection. This may fill up your Command Prompts folder, so I would recommend using /k [] instead. This allows you to supply which command file to use.

When the [] are in the "Parameters" subsection, it will prompt you with a small dialog for you to enter you command file (when using /k).

This reduces the number of objects in your Command Prompts folder, unless you like have a different color for each drive. In that case, you can use the "Working Directory" subsection and add D:\, or whatever suits your fancy.

Enjoy!

Previous Article
Home
Next Article

Copyright (C) 2002. All Rights Reserved.