Sunday, July 5, 2015

How to personalize the Windows command line

Computer support techs and other IT professionals that use the command line to run programs and perform tasks can easily get bored with the plain black background and off-white text.  Fortunately, there are several ways you can customize the command prompt -- at least a little bit -- and take away some of the monotony.

- Title

When you run the command prompt in a window (rather than full screen) the title bar of the window is usually something like "C:\WINDOWS\system32\cmd.exe" or maybe "Command Prompt."  With the TITLE command, you can change that title to anything you want.  If you want to change the header to "Is it 5:00 yet?" just type "TITLE Is it 5:00 yet?"  The title you choose will also appear on the taskbar with your other open programs, so make sure it's not something that shouldn't be seen by anyone else.

- Prompt

Staring at the same prompt all the time can get old quickly.  Some people may choose to hide it completely by using the "ECHO off" command, but you can change the prompt to say anything by typing "PROMPT <whatever you want the prompt to be>".  There are certain special symbols and tricks you can use with PROMPT, which you can see by typing "PROMPT /?".  For instance, if you want the prompt to show the current time, you could use "PROMPT $T".  (You could also make it more user friendly by doing something like "PROMPT Hello, it's$T: ".)

If you later decide you want to change the prompt back to the current drive and path, just type "PROMPT $P$G".

- Color

The COLOR command allows you to change the DOS environment foreground and background colors.  Play around with the different numbers to find a color combination you like, or search online for a chart that breaks each color down.  Typing "COLOR 18" will make your command prompt window look like an old Commodore 64 screen.

To return to the default color scheme, type "COLOR 7".

These commands can help make the command prompt more palatable for people that use it extensively, but they can easily become repetitive to type every time you open up a new window.  To simplify the process, you can make a batch file designed to create a command prompt environment that works well for you.  Maybe you want the window to display the current date and time when you first open it.  Or maybe you always go to a specific directory and view its contents (or read a log file) every time you open a command prompt window.  Batch files can easily do both of those things for you.

You could either make a batch file and run it every time you start a command line window, or you could have the batch file itself open up the command prompt, and just run that batch file from the Run bar.  (Use the CMD and then EXIT commands in the batch file to open a command prompt that won't close right back up again.)

(Originally published on Helium.com, May 2010)

No comments:

Post a Comment