Making the Windows Command Prompt Usable

April 28th 2008

If you’ve used an interactive shell on Linux or OS X you know what a good command prompt is like. To go from that to the command prompt in Windows XP is painful, since I’m stuck on Windows at work, I had to do something about the command prompt to make it more bearable.

Install Console

Console is an Open Source command prompt window enhancement. If you’re familiar with Konsole from Kde, Console has a similar feature set.

Console allows you much greater control over the display and setup of the command prompt including resizing the console, specifying background and font colors, specifying a startup directory, using tabs, etc.

There’s no installer with Console, just extract the zip file and run console.exe. I’ve created shortcuts in my taskbar and on the desktop for easy access. Once you’ve launched Consoe, be sure to spend some time playing around with the settings, that’s where all the power is!

Install Cygwin or GNUWin32

Now that we have a decent console, it’s time to get some *nix goodness! There are two great options for getting ports of *nix tools working on Windows: Cygwin and GnuWin32.

Cygwin provides a more *nix like environment, as well as a larger number of tools overall. Cygwin includes a batch file to launch a command prompt with bash as the interpreter. With Cygwin you can also install an X server and run programs that require an X server, though if you’re trying to do that it’d be much easier to install VirtualBox or VMWare Player and run a virtual instance of your favorite *nix distro.

GnuWin provides Windows ports of many *nix tools, but does not try to imitate the *nix filesystem like Cygwin does. If you’re only looking for specific tools it may be easier to get them from GnuWin32.

I’m currently using Cygwin as it’s a standard at work.

Using *nix Tools from the Windows Command Line

Now that we have our command line and our *nix tools, all that’s left is to connect the two by adding the folder with the binaries to your Windows path. For Cygwin this is c:\cygwin\bin by default.

  1. Right click on “My Computer” on your desktop (or in windows explorer)
  2. Select “Properties”
  3. Click the “Advanced” tab
  4. Click on “Environment Variables”
  5. Look at the top list of variables,
    • If there is not a variable named “Path”
      1. Click on “New”
      2. Enter “Path” in the “Variable name” field
      3. Enter “C:\cygwin\bin” in the “Variable value” field
    • If there is a variable named “Path”
      1. Click “Edit”
      2. Click in the “Variable value” box and go to the end of the field
      3. Add a semi-colon ( ; )
      4. Enter “C:\cygwin\bin”
  6. Click OK 3 times and you should be ready to go

Open Console and enjoy your much improved windows command prompt experience!

Posted by bradym under Windows | No Comments »

I’ve joined Technorati

January 3rd 2008

Since I’m planning to be more active in blogging this year, I figured joining Technorati would be a good thing to do. Check out my Technorati profile.

Posted by bradym under News | No Comments »

Opera friendly PHP redirect

January 2nd 2008

Opera can’t handle a redirect to a URL that ends in an anchor. I found this out trying to use the PHP header() function.

From what little I was able to find using Google on the topic, it appears that Opera won’t redirect a user to the page they just came from, it must be a different URI.

To get around this in php, here’s what I did:

header('Location: file.php?value1=12&value2=43&r='.rand().'#anchorName');

Having the random number from rand() makes the page unique, and the redirect works as expected.

Posted by bradym under PHP | No Comments »

Can’t get JCalendar to select a specific date when opening

January 2nd 2008

There is an error in calendar-setup.js that prevents the setting of an initial date for the calendar. Go to line 159 and replace the code:

if (dateEl) params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt);

with:

if (dateEl && (dateEl.value || dateEl.innerHTML)) params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt);

Posted by bradym under JavaScript | No Comments »

Display HTML code without having it parsed

January 2nd 2008

Sometimes it is nice to display html code with out it being parsed as html, for example if you are writing a tutorial and want to show how to do something.

To display code, you will need to use a code to display a < or > to prevent the browser from treating it like actual code.

The code to display a < is < while > is >

Displaying codes like I have just done can be a little more tricky. To display the above codes, I had to use the codes to display the & and the ; so that it wouldn’t just show you the < and >.

Confused yet? Basically to show you the code: < I actually had to type in <.

Take a look at http://htmlhelp.com/reference/charset/ for a list of codes.

Posted by bradym under HTML | No Comments »

Next »