Sqlplus is my second home, part 3: Colored selections in Windows XP command prompt

Tanel Poder


Whenever delivering some Oracle training or running a demo at a conference, I’ve always liked to use the Windows command prompt version of sqlplus.

One reason of course is its easy command line history navigation capability ( press F7 in cmd.exe after entering few commands to see why ).

Another reason is that whenever I want to highlight some part of sqlplus output, I can just drag a selection rectangle around that text. In other words I can “mark” the text – drawing the attention there. Of course as the selection rectangle is really meant for copy & paste operations only, it has several limitations. It’s not persistent, whenever I continue typing, the text “marking” will disappear.

Windows XP has introduced a really cool feature to cmd.exe, which anyone doing presentations involving some command line tool output will appreciate!

Basically XP allows you to persistently select and color command prompt output!

An example of what I’m talking about is here:

How can this be done?

First, you need to create a DWORD value in Windows registry HKEY_CURRENT_USER\Console\EnableColorSelection and set it to 1

Now launch CMD.exe, select something and press CTRL+6. The backround of text of the selection should turn red. If you press ALT+6, the foreground text should turn red.

You have 10 different colors available for your use, using key-combinations ALT+0..9 and CTRL+0..9

Also, this coloring is persistent. If you generate more output during your demos, you can always scroll back and easily spot the highlighted part quickly if need to revisit some previous result.

Nice huh? I will sure use it in my future demos and presentations!

If you want my whole CMD.exe registry key settings, copy and paste the these lines below into a .reg file and import into your registry ( after backing up your current key of course! ).

Windows Registry Editor Version 5.00

"FaceName"="Lucida Console"

I’ve configured multiple CMD.exe things from defaults for my convenience. Most of the stuff is accessible from the CMD.exe Properties menu, however the EnableColorSelection and WordDelimiters need to be set in registry.

The WordDelimiters is another handy setting. It allows you to specify where in the typed line cursor stops should you navigate left or right word-by-word using CTRL+Left/Right arrows. Normally only the space char was recognized as a word delimiter, but I’ve added many other characters as well – it’s much faster to navigate on command line that way.

  1. I am finally close to launching the completely rebuilt 2024 versions of my Linux & AOT classes in my Learning Platform! (Updates to SQL Tuning class in H2 2024):
    Advanced Oracle SQL Tuning training. Advanced Oracle Troubleshooting training, Linux Performance & Troubleshooting training. Check them out!
  2. Get randomly timed updates by email or follow Social/RSS