Skip to main content

Chapter 3 – Understanding the prompt

Chapter 3 – Understanding the prompt

 

When you start the Command Prompt program, the first thing you'll see on your screen is this:

C:\>

That is the actual command prompt itself. But what does the prompt do? What do all those symbols mean? We'll discuss how to understand and alter the prompt in this chapter. 

 

WHAT IS THE PROMPT?

 

The "prompt" that gives the Command Prompt its name is the first thing you see when you launch the Command Prompt program. What is it? To put it simply, its a series of characters that indicates the computer is ready to accept commands from you. Nowadays, you know that a computer has booted up and is ready to run programs when you see the Windows desktop. But in the days of DOS, you only knew the computer was ready when you saw the DOS prompt appear on the screen. 

The basic prompt in the modern Command Prompt looks something like this:

C:\>

Alternatively, it can have additional directory paths within itself - generally, when you launch a new Command Prompt session, it opens in your home folder, so it will probably look something like this:

C:\Users\USERNAME>

What does this all mean?

If you remember the previous chapter on drive letters, the "C" in the prompt refers to the C drive, your computer's hard drive. You can change the selected drive in Command Prompt by typing the drive letter followed by a colon. For instance, if you wanted to switch from the C drive to the D drive, you would type this and his enter at the prompt:

D:

And then prompt would change from this:

C:\>

To this:

D:\>

If the first letter in the prompt indicates the currently selected drive, the characters after the drive show the current directory and subdirectory on the selected drive. In a prompt that looks like "C:\>", that indicates you are in the root directory of the C drive, since the "\" character represents the root directory of a drive. And as you change the current directory, the prompt changes as well to show the current directory. For instance, if you change from the root directory to the Program Files directory, the prompt will look like this:

C:\Program Files>

As you change into deeper and deeper subdirectories, the prompt will accordingly become longer and longer.

The final character in the prompt, the greater than sign (>), indicates the end of the prompt and the location of the cursor. Any commands you type into the prompt will appear to the right of the greater than sign.

 

CHANGING THE PROMPT

 

The default prompt configuration is good enough for most people. However, if you would prefer to customize the prompt to show additional (or less) information, you can do so with the PROMPT command. The PROMPT command lets you alter the appearance of the prompt, while customizing it however you wish.

To test it out, type this command at the prompt:

PROMPT Hello!

You'll notice that the command prompt immediately changes from "C:\>" to "Hello!" While having the prompt say "Hello!" seems quite friendly, it nonetheless contains no useful information. To change it back, type this command at the modified prompt:

PROMPT $P$G

The prompt will then change back to the more familiar "C:\>".

As you might guess, the PROMPT command lets you do more than simply put friendly (or snarky) messages in the command prompt. The PROMPT command responds to a series of variables, and will modify the prompt to display information based on those variables. In the above example, the $P variable refers to the current location, and the $G variable refers to the greater than sign. So when you issue a PROMPT command with the variables in this order, you'll return to the prompt to its default state:

PROMPT $P$G

Here are some the more useful variables you can use with the PROMPT command to enhance the default command prompt:

-$D adds the current date to the prompt.

-$C adds a left parenthesis.

-$F adds a right parenthesis. You can use this in conjunction with $D to place information provided by the other variables with a set of parentheses. 

-$N displays the currently selected drive. 

-$P displays both the currently selected drive and the currently selected location on that drive. 

-$T shows the current time.

-$V shows the Windows version number. 

You can get a complete list of variables for the PROMPT command by using it with the /? switch:

PROMPT /?

(As we mentioned earlier, using the /? switch with any command will provide a list of options for that command. It's a useful switch to remember, in case you can't recall the switches available for any one command.)

Let's combine these variables in a few separate examples. (You can always return to the default prompt with the PROMPT $P$G command if you make a mistake.) Say you wanted the prompt to show the current date and time along with the drive and location. You would use this command:

PROMPT $P$G$D$T

This would alter the prompt to show the current date and time:

C:\>Sun 08/28/201115:08:14.47

However, that prompt looks rather cluttered. It might work better if you put a space between the date and the time with this command:

PROMPT $P$G$S$D$S$T

The resultant prompt would look like this:

C:\> Sun 08/28/2011 15:09:17.24

By playing around with the PROMPT command and its variables, you can customize the prompt to your liking. 

 

CHANGING THE TITLE BAR

 

By default, the title bar of the Command Prompt window reads simply "Command Prompt." You might want to change it to show more information - if you have multiple Command Prompt windows open, changing the title bar is a quick reminder to let you know what task you are performing in each window. Or you could simply change it for your own amusement.

You can change the text of the title bar with the TITLE command. For instance:

TITLE Hello!

This will change the text of the Command Prompt window from "Command Prompt" to "Hello!"

 

CHANGING THE TEXT AND BACKGROUND COLOR

 

When you launch a new Command Prompt window, it shows white text on a black background. This a throwback to the old DOS prompt, which always booted up with white text on a black background (or green text on a black background) in order to reduce the chance of the old-style tube monitors burning the text onto the screen. Fortunately, tube monitors have becoming increasingly rare (I don't miss carrying them from building to building) and flat-panel LCD monitors have taken their place.

Reading white text on a black background for a long period of time can put strain on your eyes. If you want to change the color of the Command Prompt's text or background, you can do so with the COLOR command.

The COLOR command generally looks like this:

COLOR 07

If you entered this command at a default Command Prompt window, nothing would happen. Why not? COLOR 07 sets Command Prompt to use white text on a black background. The first digit sets the background color, and the second digit sets the text color. So, COLOR 07 sets Command Prompt to use a black background and white text.

Here is the complete list of codes to use with the COLOR command:

-0, Black.

-1, Blue.

-2, Green.

-3, Aqua.

-4, Red.

-5, Purple.

-6, Yellow.

-7, White.

-8, Gray.

-9, Light Blue.

-A, Light Green.

-B, Light Aqua.

-C, Light Red.

-D, Light Purple.

-E, Light Yellow.

-F, Bright White.

For instance, if you wanted to set the Command Prompt to use white text on a black background, you would use COLOR with these options:

COLOR 70

Or, if you wanted to set Command Prompt to use green text on a black background (to make it look a bit like "The Matrix" science fiction movies), you would use this command:

COLOR 02

Finally, if you make a typo and the Command Prompt is displaying some hideous mixture of colors, like blue text on a black background, simply type the COLOR command without any options. Entering COLOR without any codes after it will reset the prompt back to white text on a black background. 

Comments

Popular posts from this blog

Chapter 7 - Copying, moving, renaming, and deleting files.  

Chapter 7 - Copying, moving, renaming, and deleting files.   we will discuss the basics of managing your files from the command line.   COPYING FILES   One of the most useful features of the modern PC is the ability to swiftly copy files from one location to another. Practically every computing device has the ability to copy files. The Windows operating system and the Command Prompt are no different. The basic command for copying files from the Command Prompt is the COPY command. If you wanted to use COPY to copy a file called test.txt to the root directory of a USB flash drive assigned the letter J: COPY test.txt J:\ The command will create a copy of test.txt in the root directory of the J drive. Like most Command Prompt commands, COPY assumes that you will be copying files from the working directory, and looks there first to find the filenames you specify. However, you can also use COPY with absolute file paths. If test.txt were in the Users directory of the C...

Gallery

photos
How to slide in Word Procedure is useful for creating presentations on PCs without PowerPoint By Helito Beggiora, for TechTudo 08/04/2019 08:01 Updated há 16 horas You can create slides in Word with a few simple settings. The feature is useful if your PowerPoint application is in trouble and you need to produce a presentation in a hurry. To do this in the text editor, you need to make adjustments in the orientation and size of the sheets, change the margins, and manually insert titles and topics into large fonts. In the following tutorial, check out how to make slides in Word from the PC. The procedure was performed in the latest version of Office 2016 , but the tips are also valid for users of previous editions of the Microsoft program . Eight hidden functions of Word that will streamline your work How to insert line in Word Want to buy cell phone, TV and other discount products? Compare TechTudo Step 1. Open a new Word document and go to the "Layout" tab. Then go...