Tips and Tricks to Customize Your Command-Line (CMD) Experience

The Command Prompt, also referred to as Command-Line or CMD, is a text-based program used to issue commands to your computer operating system. Prior to a development of an operating system with a graphical interface (such as Windows) where you interact with it with mouse clicks, the Command Prompt (aka DOS prompt) was the primary means to use a computer. It involved typing command in the proper syntax to get a computer to perform various task - such as copying a file, re-naming a file, or launch a program.

Today, the Command Prompt is a useful tool used typically by system administrators, help desk technician or similar to troubleshooting or administer a system. The Command Prompt typically provides a less abstracted interaction with the operating system and provides greater functionality and efficiency over a graphical interface.

This article goes overs some tips and tricks to help you customize your Command Prompt for a better experience. These commands shown here are tested on Windows 10 but most will work in other versions of Windows as well. In the article, we will cover the following:


How to Open Command Prompt

To use this utility, you will need to launch the Command Prompt window. The three common ways to launch the Command Prompt window are:

  1. Search for cmd using the built-in Windows search tool.
  2. Right-click on the Start icon and select Command Prompt.



  3. Press the keyboard combination WinKey + R, then type cmd at the Run window that appears.

    Run cmd

Customize the Prompt

The default prompt can be customize to show a variety of information. For some, your default prompt may look like the one illustrated below.

Command Window Default Prompt

Prompt Help Page

If you work in the command window often, you may find it useful if the prompt include other information such as the current time and folder path. To see a list of available options, bring up the help page by typing in the following then pressing Enter, prompt /?. A help page like the one illustrated below appears to shows you a list of available options.

Command Prompt Help

Example of Custom Prompts

To change your prompt to include the current timestamp and the current drive letter and folder path, type the following and press Enter: prompt $T $B $P$G

Command Window Prompt Custom Example

As shown in the help page, the $T signifies the current timestamp, the $B is the pipe symbol (vertical line). It's purpose here to is serve as a visual divider. The $P signifies the current drive letter and folder path. Finally, the $G is the greater-than symbol and it is used as a visual aid to the user that they what they type will appear to the right of this symbol.

You can even include your own text in the prompt. For example, to change your prompt to read Death Star, type prompt Death Star$G then press Enter.

Command Prompt Death Star Example

Reset Your Prompt Back To Default

To reset your Command Prompt to your computer's default, type in prompt then press Enter



Customize the Title Bar

The command window title bar, illustrated below, can also be customized with your own text.

Command Prompt Window Title Bar

Example of Custom Title Bar

As an example, to change your Command Prompt title bar to read Death Star Console, type in title Death Star Console then press Enter

You should see your title bar change as illustrated below.

Command Window Title Bar - Custom Example


Changing the Background and Text Color

The background color and the text color can be changed to a handful of color combinations. To see a list of available colors, type in color /? then press Enter

Command Windows - Color Help

As shown on the help page, there are 16 colors to choose from for both your background and text color. It should be noted that you will not be able to change both your background and text to the same color. As an example, to change the background to green and the text to black, type in color 20 then press Enter. The first digit (2 in this example) sets the background to green. The second digit (0 in this example), sets the text color to black.

Windows Command Prompt - Color Example

Reset Back to Default Colors

To reset your Command Prompt colors to your computer's default, type in color then press Enter.



Running Multiple Command on the Same Line

If you have a series of commands to run, you can string them together on the same line to execute them, as oppose to typing in one command per line. To do this, all you need is to is type && between each of your commands. For example, to change the title bar to read Death Star Console and text color to green, type in the following then press Enter: title Death Star Console && color 2

Command Prompt - Multiple Commands Per Line


Copying Text from Command Prompt Window

Copying text from a Command Prompt Window isn't the same as copying text from a Word document. Follow the steps below to copy text from Command Prompt Window.

  1. Right-click anywhere on the Command Prompt Window.
  2. Select Mark from the popup menu, as illustrated below.

    Command Prompt Mark Text

  3. Click and hold the left mouse button to highlight the text area you want to copy, as illustrated below.

    Command Prompt Copy Text

  4. Press Enter on your keyboard. Your highlighted text is now copied to the Windows clipboard. You can now open Notepad, Microsoft Word or almost any other application where you can then paste your text into.

Clear the Screen

If you want to clear your Command Prompt window of previous commands you've typed in, type in cls then press Enter.

Your Command Prompt windows will be cleared as illustrated below.

Command Prompt


How to Make Your Customization the Default

The customization described in this article are all temporary. Once you close the Command Prompt window, your changes are lost. The next time you launch Command Prompt, all your customization are reverted back to their default settings. To make your specific customization the default so that it always show when you launch Command Prompt, you will need to make a registry edit.

Instructions

  1. Press the keyboard combination WinKey + R to open the Run window.
  2. Type regedit then press Enter.
  3. When the Registry Editor window appears, navigate to HKEY_CURRENT_USER\Software\Microsoft\Command Processor

    Registry Editor - Command Processor

  4. On the right pane, right-click on an empty space and select New > String Value.
  5. Name this as Autorun.
  6. Right-click on this Autorun and select Modify.
  7. In the Edit String dialog box, enter your customization in the Value Data text box in the same manner as described above. Using the examples above, to change the title bar to read Death Star Console, the prompt to read Death Star, and the text color to green, type in title Death Star Console && prompt Death Star$G && color 4 then press OK.

    Registry Edit - Command Processor - Autorun Example

  8. Exit Registry Editor. Your customization are now set as default. Each time you launch Command Prompt, the customization you've defined here will be applied.

Removing Your Default Customization

If you no longer want the customizations you've defined in the registry, you can revert back to your Windows default by deleting the Autorun key created in the previous step.


Forcibly Terminate Any Command Mid-Operation

Press CTRL + C aborts the current running task.


Drag and Drop Folders to "Paste" its Directory Path

When you need to provide a directory or folder path to a command, instead of typing it, you can do so more efficiently and accurately by dragging and dropping the file or folder from your File Explorer to your Command Prompt window.

The in illustration below, right-click and hold on the file named "host", dragging it to your Command Prompt window, and then release the mouse button will automatic insert the location path to the file. In this example, the file path automatically inserted in the Command Prompt window is "C:Windows\Systems\drivers\etc\hosts"

Command Prompt - Drag-and-drop folder path


Shutdown Your Computer with a Timer

A shutdown command is available that is used to either shutdown and restart a computer, along with other available actions. For example, to shutdown your computer automatically in one hour, type in your Command Prompt window shutdown /s /t 1800 then press Enter. The /s option is to specify a shutdown (as oppose to a restart with the /r option). The /t option is to specify the shutdown is to occur using a timer. And in this case, the timer is set to 1800 seconds (or 30 minutes).

Cancel a Scheduled Shutdown

If you cancel a scheduled shutdown, you can abort it by typing the command shutdown /a then press Enter.


Recommended Reading


Improve confidence and job performance

Improve productivity and efficiency

Learn more,
earn more

Life-long
investment
To learn more about this topic, we are providing you with recommendations to help you further your knowledge. These are our affiliate links to Amazon where you can purchase them and also explore a variety of other relevant books.




Suggestion

Windows Command Line Administration Instant Reference



Buy from Amazon

Suggestion

Microsoft Windows Command-Line Administrator's Pocket Consultant



Buy from Amazon

Suggestion

Windows PowerShell Cookbook: The Complete Guide to Scripting Microsoft's Command Shell



Buy from Amazon