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

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

[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:00000000
"ColorTable01"=dword:00800000
"ColorTable02"=dword:00008000
"ColorTable03"=dword:00808000
"ColorTable04"=dword:00000080
"ColorTable05"=dword:00800080
"ColorTable06"=dword:00008080
"ColorTable07"=dword:00c0c0c0
"ColorTable08"=dword:00808080
"ColorTable09"=dword:00ff0000
"ColorTable10"=dword:0000ff00
"ColorTable11"=dword:00ffff00
"ColorTable12"=dword:000000ff
"ColorTable13"=dword:00ff00ff
"ColorTable14"=dword:0000ffff
"ColorTable15"=dword:00ffffff
"CursorSize"=dword:00000019
"FaceName"="Lucida Console"
"FontFamily"=dword:00000036
"FontSize"=dword:000e0000
"FontWeight"=dword:00000190
"FullScreen"=dword:00000000
"HistoryBufferSize"=dword:000001f4
"InsertMode"=dword:00000001
"LoadConIme"=dword:00000001
"NumberOfHistoryBuffers"=dword:00000004
"PopupColors"=dword:00000007
"QuickEdit"=dword:00000001
"ScreenBufferSize"=dword:270f03e8
"ScreenColors"=dword:00000070
"WindowSize"=dword:0032009c
"CurrentPage"=dword:00000002
"HistoryNoDup"=dword:00000001
"WordDelimiters"=";:,.[]{}()/\|^&*-=+"
"EnableColorSelection"=dword:00000001

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.

Note that this year’s only Advanced Oracle Troubleshooting class takes place in the end of April/May 2014, so sign up now if you plan to attend this year!

This entry was posted in Cool stuff and tagged , . Bookmark the permalink.

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

  1. tanelp says:

    Note that I updated the .reg file contents just now and put back the backslashes the wordpress editor had stripped previously…

  2. Sidhu says:

    Good one Tanel

    A new thing for me, really nice :)

    Sidhu

  3. Dan says:

    Good stuff! This will definitely be helpful when doing presentations or teaching a class. Thanks for summarizing it so nicely.

  4. Pingback: DanNorris.com » Monday (on a Tuesday) morning finds

  5. Satish says:

    Interesting feature!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>