0

How to find the command prompt ANSI escape code for the right-angle-quote »? (» in html) I'd like to use this symbol for my CMD prompt shell instead of the default angle bracket >*

While the impetus for asking is seeking a single character, it would be good to have a general answer for looking up any character.

There are many helpful pages for setting colours and controlling character position but I haven't found any that explain how to use ANSI symbols in general.

* (Inadvertent copy-paste into a prompt which includes > is interpreted as redirect output to file, which can have unpleasant results.)

matt wilkie
  • 5,324

2 Answers2

1

Your HTML link listed raquo with the hex code of BB.

To enter this character in (almost) any application on Windows:

  • Press and hold the Alt key
  • Press the + key in the numeric pad
  • Press the b key twice
  • Release the Alt key.

For more information see the article
How to Use ALT Codes to Enter Special Characters & Symbols Using a Keyboard.

harrymc
  • 498,455
1

Hahaha! I was way over thinking the problem. The codes are not needed, just paste the character as is into the set prompt string. Or if typing it out use the sequence shown in @harrymc's answer

So set prompt=CMD$S$P$_»$S result:

CMD C:\Users\Matt
»

And a more complicated version with colours:

rem Allow (some) Unicode (https://ss64.com/nt/chcp.html)
chcp 65001

set prompt= $E[m$E[32mCMD$E$S$E[92m$P$E[90m$_$E[90m»$E[m$S$E]9;12$E`

screenshot

Also I learned that ANSI is actually an ill-defined term that could mean any of several things, but in this context the practical definition is Windows code page 1252; see this wikipedia page for explanation and a chart that can be copied from.

On my system setting the code page to Unicode first with chcp 65001 is needed in batch files but not when when setting the prompt interactively, where chcp remains at the default of 437. I don't know why that is.

matt wilkie
  • 5,324