In DOS, there is a "prompt" command that allows you to change the text that shows up to the left of your cursor. I think the default is to just show the name of the current directory.

When I'm running long commands in DOS (below is a short example), I often need to scroll back to the beginning of the command output, which can be hard to find if you've been running a lot of commands in a row.

enter image description here

Is there a way to change the COLOR of the text in the prompt? I know that I can put newlines in the prompt too, which does help, but since color codes are supported in other output, I'm hoping there's a way to change the prompt color too.

And the for the love of whatever you hold dear, please do not reply and tell me how to change the background color or text color of the overall DOS Prompt window. I only want to change the color in the prompt, like how this is shown with bold (I guess StackExchange doesn't support color!):

C:\Users\tuttlj>mkdir npmtest

C:\Users\tuttlj>cd npmtest

C:\Users\tuttlj\npmtest>npm install node-sass

node-sass@4.12.0 install C:\Users\tuttlj\npmtest\node_modules\node-sass node scripts/install.js

Cached binary found at C:\Users\tuttlj\AppData\Roaming\npm-cache\node-sass\4.12.0\win32-x64-57_binding.node

node-sass@4.12.0 postinstall C:\Users\tuttlj\npmtest\node_modules\node-sass node scripts/build.js

Binary found at C:\Users\tuttlj\npmtest\node_modules\node-sass\vendor\win32-x64-57\binding.node Testing binary Binary is fine npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\tuttlj\npmtest\package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\tuttlj\npmtest\package.json' npm WARN npmtest No description npm WARN npmtest No repository field. npm WARN npmtest No README data npm WARN npmtest No license field.


This is possible. Here is an example done on Windows 10:

enter image description here

You may see above the two methods : The prompt command and the PROMPT environment variable. Setting the environment variable for System or User gives the same result as using the PROMPT command, except that it will apply to all new Command Prompts.

The color sequences look like $e[<number>m and they can be combined.

This is documented by Microsoft in Text Formatting.

The special functional terms, like $P for the current drive and path, can be listed by running prompt /?.

| improve this answer | |
  • Just what I needed! Thanks for the documentation and a couple examples! – jimtut Aug 5 '19 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.