You are here: Home Magazine 2001 issues July 2001 Mine tastes like purple

Mine tastes like purple

Colors are cool and that extends to computing as well.

by James Cannon

A lot of TV commercials are stuck in my head, and among my favorites is one ad with several kids eating yogurt (or was it ice cream)? Each kid described the flavor of his dish: "Mine tastes like Ba-nan-na!" Finally, one kid said, "Mine tastes like purple." Indeed, colors are a cool thing, and that extends to computing as well.

One way 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 just one color.

A lot of the power of OS/2 lies in the Properties of an object, in this case, the OS/2 Command Window and OS/2 Full Screen object. An OS/2 command session can be used in conjunction with a command file (which always has a CMD extension). If you add /k to the "Parameters" subsection, you can pass command files to modify the OS/2 Command Session.

Find the OS/2 Command icon on your desktop, or better yet, create a new one so you can experiment with this tip. Look at its properties. Look for the "Optional" section and specifically, the "Parameters" subsection.

2001-07-purple.gif

Now to add color choices to your system. Create a number of .CMD files, and make sure they're in a directory that's on the PATH listed in your CONFIG.SYS file. I put mine in C:\OS2, which is where CMD.EXE lives. I created BLUE.CMD, CYAN.CMD, GREEN.CMD, MAGENTA.CMD, RED.CMD, and YELLOW.CMD, all 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]

 

As you'll notice the format is quite similar. First ANSI is turned on (the @ character hides a command's display, but not its output). Next, we start the prompt sequence.

The $e begins use of ANSI escape sequences, starting with [ then we have our color combos. Foreground first: 31 for red, 32 for green, and so on. To set the background to black, include the 40. If you want a different background color, add ten to the foreground number: 32 (green) + 10 = 42 gives a green background. I'm not sure what the m$i does, but going to the prompt $p$g requires a [ preceding it. Finally, the instruction is ended with ].

You can also set colors with a brightness intensity, as follows:

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 our color (35=magenta, 31=red). This is followed by a 1 for brightness.

Once you set up all your command files, you can add them to the Command Prompt's properties using /k in the Parameters subsection. But, because creating several objects may fill up your Command Prompts folder, I would recommend using /k [] instead. This allows you to supply which command file to use.

2001-07-purple-a.gif

When the brackets [] are included in the "Parameters" subsection, OS/2 will prompt you with a small dialog box, so you can enter the command file name (when using /k).

2001-07-purple-b.gif

Doing so reduces the number of objects in your Command Prompts folder. On the other hand, it could be convenient to use a different color for each drive. In that case, use the "Working Directory" subsection and add D:\, or whatever suits your fancy.

Enjoy!

Document Actions