28

As we all know, Windows command-line have the white-black color scheme. And we could use:

COLOR

command to change the colors of background and text.

But the command above will change the whole text in the command-line. E.g. the result of command is as follows:

COLOR 04

enter image description here

But I don't want this kind of color-scheme because that makes no difference with the original white-black one. It is hard to distinguish the command you input and the output of the command. What I want is something like this:

enter image description here

I want the color of command prompt is different with other text on the screen so that I can find the command I input easily. But I only get the solution on Linux. It uses:

export PS1=”\[\e[35;1m\][\u@\h: \W]\$\[\e[0m\] “

So my question is:

How can I change the color of command prompt like the above one on Windows?

Thanks very much.

Solution:

Following the prompt of @Luke I finally get the solution. Anyone who is interested in this topic please hit the two links below:

https://stackoverflow.com/questions/6297072/color-for-the-prompt-just-the-prompt-proper-in-cmd-exe-and-powershell & http://gynvael.coldwind.pl/?id=130

It is "ANSI hack developped for the CMD.exe shell".

Wish that would be helpful for you.

5
  • 1
    The native Windows command prompt is not this configurable; you'll have to use a 3rd party solution.
    – Luke
    May 22 '12 at 2:08
  • 1
    @Luke Is there any existing 3rd party solution you know?
    – cloud
    May 22 '12 at 2:35
  • @Luke, Citation needed for such an assertion.
    – Pacerier
    Aug 24 '15 at 9:40
  • Is it possible to make the command output a different color than the command itself?
    – mbomb007
    Oct 3 '19 at 18:41
  • This is a question -AND- answer site, not a question answer site. Please do not put the answer in the question. It elongates the text that must be read before getting to the answer, doesn't allow people to vote on the answer so better answers get moved to right underneath the question, and doesn't encourage other people to look at other answers for different ways to address what might be the same, or different, symptoms.
    – user66001
    Apr 7 '20 at 15:51
34
  1. Get ANSI color support:
  • NOTE: Current/Updated Windows 10 console already supports ANSI

  • Install ANSICON (source) for ANSI support in legacy windows consoles.

  • Hyper supports ANSI colors.

  • ConEmu supports ANSI colors.

  1. Setup your command prompt via environment settings...
  • Click / press Start
  • type env
  • Click Edit environment variables for your account
  • Edit / Add a PROMPT variable

  1. More information on prompt options
  1. My own prompt...
  • $_$E[1;30;40m[$E[0;36;40m%computername% | %userdomain%\%username%$E[1;30;40m] $E[0;33;40m$M$_$E[35;40m$d$s$t$h$h$h$h$h$h$_$E[1;33;40m$p$_$E[1;30;40m$g $E[0;37;40m
  • $E - escape character
  • $E[...m - ANSI Color Sequence
  • $_ - New line
  • $d - Date
  • $t - Time
  • $h - Backspace (get rid of seconds and fractional seconds)
  • $p - Current Path
  • $m - Mount Path (if in a mounted drive)
  • $g - Greater than sign
5
  • I've set %prompt% tojavascript:var str = '$_$d, $t → $p:$_'; for(x=0; x<511-str.length; ++x)document.write('='); document.write(str);. It doesn't require any 3rd party apps and solves the problem color is trying to solve.
    – Pacerier
    Aug 24 '15 at 10:36
  • @Pacerier do you have a url or reference to the support of javascript: for a prompt environment variable?
    – Tracker1
    Jan 23 '16 at 0:23
  • @Tracker1, No it doesn't work that way. I see the confusion now.... I meant , I've set %prompt% to the output of javascript:var str = '$_$d, $t → $p:$_'; for(x=0; x<511-str.length; ++x)document.write('='); document.write(str);
    – Pacerier
    Jan 23 '16 at 4:41
  • For anybody else here's a simpler example: $_$E[1;30;40m$p$g $E[1;37;40m. The 'bold' option is not actually bold at all - it just makes the color be off the set color. Shame you can't color the user input differently from the command output.
    – Unknow0059
    Sep 5 '20 at 4:43
  • 1
    @Unknow0059 for that, whatever is providing the output would need to change the color.
    – Tracker1
    Sep 6 '20 at 7:24

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