How to Permanently Customize Your Windows CMD Prompt C:\>

I previously wrote on how to change/customize your python interpreter to show your preferred text as the prompt.

See the post here: https://geekypage.com/use-custom-prompt-python-interpreter-shell/

Then, i thought that post is for we pythonista. How about one for the general.

Like:

We need another one for the whole general, then i decided we should customize your windows command prompt’s prompt this time.

I don’t know about you but i am actually fed up of the windows cmd prompt.

It’s always the same format – the current path + the greater than sign. C:\>

Why don’t we use something different plus it will make you look cool and geeky. After all you ‘re on GeekyPage. LoL

What You Should Know

You should know Windows has a builtin tool called prompt for changing the cmd prompt.

But typing prompt at the command line will do nothing, it just takes you to another line.

The simple format for the prompt command is

C:\>prompt <text>

where <text> is the new prompt to be used. for example issuing “prompt hello_world” will change your prompt to hello_world .

cmd-change_prompt1

You can try this right away.

This isn’t enough, we need more flexibility and the good news is prompt has a whole lot of special codes that let’s you use special texts

Below list shows the special codes

  $A   & (Ampersand)
  $B   | (pipe)
  $C   ( (Left parenthesis)
  $D   Current date
  $E   Escape code (ASCII code 27)
  $F   ) (Right parenthesis)
  $G   > (greater-than sign)
  $H   Backspace (erases previous character)
  $L   < (less-than sign)
  $N   Current drive
  $P   Current drive and path
  $Q   = (equal sign)
  $S     (space)
  $T   Current time
  $V   Windows version number
  $_   Carriage return and linefeed
  $$   $ (dollar sign)

We need to combine these codes to get us what we want. All codes has their own meaning and is a placeholder for a type of data such as the current time of the day.

I will cite some examples using the special codes .

Let’s say we want to set the prompt to look like the default prompt but i’m to use the dollar sign instead of the greater sign. something like C:\Users\BOLDMAN$ instead of C:\Users\BOLDMAN>

C:\>prompt $P$$

$P is for the current path, while $$ is the dollar sign. Scroll back and check the table for the codes.

You can use whatever text you want for the prompt. Everything will be interpreted normal except for the special code since they have special meaning.

custom command prompt

and the above was achieved with the below command

C:\>prompt $C$T$F$B$P$S$$

The above should be self explanatory if you look through the special code table above.

But I can explain as well to make things clearer.

$C is for opening Parenthesis, opening bracket as you know it. I used it to enclose the time in the prompt.

$T is the code for the current time

$F is used to close the parenthesis, closing bracket as you know it.

$B is for the ampersand – |. I used it to separate the time and the current path.

$P is the current path.

Lastly, $$ is the dollar sign. Using one dollar sign won’t work for you. You need to use two dollar sign code to denote 1 dollar sign in the prompt. I wanna made it use seem like the Unix Prompt just some recipes.

All straight forward, All you need is the table codes.

I ended up using something like the below prompt in my command prompt.

custom command prompt

Before we go on to make this permanent, i need to make somethings clear to you and it’s so important to better grasp what’s going here.

There is an environment variable called prompt.

It’s in this variable that the prompt text is stored. So all the prompt utility does is also set this variable to whatever text or special code you specified.

To confirm this, type the below command in the command prompt.

C:\>set prompt=$C$T$F$B$P$S$$

When you run the command above, the prompt will change like you used the prompt utility. This proves environment variable prompt controls everything.

Making things permanent

Now that i made it clear that the prompt environment variable holds the text of the command prompt, i’m pretty sure you can make the above changes permanently without reading the rest of this post.

But, i still have to go on because of the newbies in the house.

You need to set the environment variable ‘prompt’ to whatever you deem fit.

To permanent this, we just need to set the prompt variable to our text.

You can either do this through the Control Panel or alternatively with the setx command from the command prompt.

C:\>setx prompt $C$T$F$B$P$S$$

Remember you need to run the command prompt as administrator.

The above command sets the environment variable, prompt, to the prompt text. Our text.

You should read this post on how to set environment variables on windows.

After the environment variable has been set, your prompt should be persistence. So, whenever you restart your system, it’s still there.

Rolling Back To Default

Who knows, You might want to revert back to the default windows command prompt trick.

The below command will do the trick.

 prompt $P$G

This concludes this blog post

If you have any question or contribution to make this article, please you feel free to drop a comment below.

I will be more than happy to reply you ASAP.

2 Comments

  1. shell
    • admin

Leave a Reply

Ad Blocker Detected

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Refresh