Mindfulness

How to change prompt in cmd

Updated · By the Relaxmid editors

Reading time
3 min
Sections
8
Topic
Mindfulness

The Windows Command Prompt (cmd) shows a default prompt like C:\> that tells you the current drive and folder. You can change this prompt temporarily for the current session or permanently for all future sessions using the prompt command or system settings. The method differs slightly between a temporary change and a permanent one.

Change the prompt for the current session only

This change lasts until you close the Command Prompt window. It is useful for testing or when you want a custom prompt for a specific task.

  1. Open Command Prompt by pressing Win + R, typing cmd, and pressing Enter.
  2. Type prompt $g and press Enter to set the prompt to a simple greater-than sign (>).
  3. Try other codes: prompt $p$g restores the default (folder path followed by >), prompt $t $g shows the current time, and prompt hello $g displays 'hello >'.
  4. To see all available codes, type prompt /? and press Enter.

Make the prompt change permanent for all future sessions

This sets the prompt every time you open Command Prompt, so you do not need to re-enter the command each time.

  1. Press Win + Pause to open System Settings, or right-click Start and choose System.
  2. Click 'Advanced system settings' on the right, then click the 'Environment Variables…' button at the bottom.
  3. Under 'User variables' (for your account only) or 'System variables' (for all users), click 'New…'.
  4. Enter PROMPT as the variable name and your desired prompt string as the value, for example $p$g for the default or $t $g to show the time.
  5. Click OK on all open windows to save the changes.
  6. Open a new Command Prompt window to see the updated prompt.

Where it fits: common mistakes and what each one causes

  • Using set PROMPT=... instead of prompt or environment variables: This does not affect the Command Prompt display; only the prompt command or PROMPT environment variable changes the prompt.
  • Setting the PROMPT variable under System variables without admin rights: This may fail silently; use User variables instead if you lack administrator privileges.
  • Including unsupported characters in the prompt string: Some special characters may cause display issues or be ignored; stick to the documented prompt codes like $p, $g, $t, $d.
  • Forgetting to open a new Command Prompt after making a permanent change: The change only applies to new windows; existing sessions retain the old prompt until restarted.

Before-you-start checklist

  • You have access to a Windows computer with Command Prompt available.
  • You know whether you want a temporary change (current session only) or a permanent one (all future sessions).
  • You have decided what prompt format you want, such as showing time, path, or custom text.
  • You can access System Properties via Win + Pause or the Start menu.

Symptom / cause / fix table for when it goes wrong

Symptom Cause Fix
Prompt does not change after typing prompt Command typed with a typo or unsupported code Retype the command carefully; use prompt /? to verify valid codes
Prompt reverts to default after closing and reopening cmd You made only a temporary change, not a permanent one Set the PROMPT environment variable as described in the permanent change steps
New Command Prompt still shows old prompt after setting PROMPT variable Variable set under System variables without sufficient permissions, or typo in value Use User variables instead, or double-check the variable name and value for accuracy
Prompt shows strange characters or does not display correctly Unsupported or conflicting characters in the prompt string Use only documented prompt codes ($p, $g, $t, $d, $_ etc.) and avoid raw special characters

An Example of useful prompt formats

Here are practical examples you can copy directly into the prompt command or PROMPT variable:

  • prompt $p$g – Standard format: shows current drive and path followed by > (e.g., C:\Users\Name>)
  • prompt $t $g – Shows current time: (e.g., 14:30:00.50 >)
  • prompt $d $s$t$g – Shows date and time: (e.g., Mon 05/20/2024 14:30:00.50 >)
  • prompt [$_$p]$_$g – Path in brackets on its own line, then > on new line: (e.g., [C:\Users\Name]\n>)
  • prompt $n$g – Shows only the computer name: (e.g., DESKTOP-ABC123>)

How to check if your prompt change worked

  1. After making a temporary change, look at the prompt line immediately after pressing Enter on the prompt command.
  2. After making a permanent change, close all Command Prompt windows and open a new one.
  3. Verify the prompt displays exactly as you set it, based on the codes used.
  4. If it does not match, repeat the steps and check for typos in the command or variable value.

Related

General information for everyday wellbeing, not medical advice. If something affects your health, sleep or mood for more than a short while, talk to a qualified professional. Read more

Spotted an error? Tell us and we will correct it (corrections policy).