I want to know how to customize prompt using emoji in Windows terminal, since Linux/Mac shell support it years ago. I guess Windows terminal can support it now or later. But I tried, still not konw how to do it. Could @shanselman or any one else give some guide for this? 馃榿

Related Links:
How to Customize your Terminal Prompt (for Mac)
This new Windows Terminal will include emoji support

@mdtauk
Thanks, but pity that you misunderstand my question. I ask about customize prompt in Windows Terminal, not about input emoji into Windows Terminal (you mentioned). They are completely two things.
What I need is like this:

Yes, although there are some bugs being worked out:

Yes, although there are some bugs being worked out:
@binarycrusader Oh, cool. How to do it? Need code change manually? Or just achive it with some configurations.
It depends on what your shell is.
For cmd.exe, you can set your prompt with the PROMPT command for the current instance, or setx PROMPT to set it for future cmd.exe instances. You might run into other issues though, because cmd.exe doesn't support utf-8 by default, so you'll probably need a chcp 65001 somewhere before that to get it to work right. cmd.exe also doesn't support empji on the input line quite yet, so you'll probably also need to use a batch script to actually set it.
As far as powershell goes, I don't actually know how to set the powershell prompt. Someone else might be able to help you there.
@zadjii-msft The PowerShell prompt is just a function named prompt that returns a string.
This is better than an environment variable, IMHO, since you can make it more dynamic this way.
P.S.: I use PowerLine for PowerShell as my prompt of choice nowadays.
@ExE-Boss I am also using PowerLine for聽PowerShell, I am looking forward to the accurate reply of @binarycrusader. Thanks~
@yanglr There are bugs in unicode display right now that are already known, and if you do this, the prompt won't look correct in the old powershell window.
However, these are the steps to take if you want to experiment:
function prompt { "PS $pwd>" }
Remember, your emoji prompt won't work in the old powershell window, it will display weird character boxes or something else there. Also, note that the display of some characters may not work as expected.
@binarycrusader
OK, cool. I will try, thanks so much~ 馃憦
For cmd.exe, you can set your prompt with the
PROMPTcommand for the current instance, orsetx PROMPTto set it for future cmd.exe instances. You might run into other issues though, because cmd.exe doesn't support utf-8 by default, so you'll probably need achcp 65001somewhere before that to get it to work right. cmd.exe also doesn't support empji on the input line quite yet, so you'll probably also need to use a batch script to actually set it.
CMD uses the console's wide-character API. The command line is read via ReadConsoleW, and the prompt is written via WriteConsoleW. Also, the PROMPT environment variable is Unicode, so UTF-16LE surrogate pairs in its value get passed along to the console via WriteConsoleW.
CMD uses the console output codepage (i.e. GetConsoleOutputCP) when decoding byte strings, such as when reading a batch script (decoded line by line) or when reading from the pipe in a for /f loop. chcp.com sets both the input codepage and output codepage. We can use chcp.com 65001 to work with UTF-8 string literals in a batch script. Just take care to not save the file with a BOM since CMD doesn't ignore it. Also, at the start it's good to save the current input codepage from chcp.com, so it can be restored at the end.
It's especially important to not leave the input codepage set to 65001, since this limits legacy applications to 7-bit ASCII if they read from the console via ReadFile or ReadConsoleA. The console's bytes API still doesn't support reading the input buffer as UTF-8 since it makes the simple-minded assumption of 1 (ANSI) byte per character, whereas UTF-8 is 1-4 bytes per character. WideCharToMultiByte is called per character and fails if any character requires more than 1 byte, in which case it's read as a NUL byte (e.g. "SP膧M" is read as "SP\x00M" instead of UTF-8 "SP\xc4\x80M"). If we restore the previous codepage (probably OEM), at least it supports about 128 non-ASCII locale characters.
For cmd.exe, you can set your prompt with the
PROMPTcommand for the current instance, orsetx PROMPTto set it for future cmd.exe instances. You might run into other issues though, because cmd.exe doesn't support utf-8 by default, so you'll probably need achcp 65001somewhere before that to get it to work right. cmd.exe also doesn't support empji on the input line quite yet, so you'll probably also need to use a batch script to actually set it.CMD uses the console's wide-character API. The command line is read via
ReadConsoleW, and the prompt is written viaWriteConsoleW. Also, thePROMPTenvironment variable is Unicode, so UTF-16LE surrogate pairs in its value get passed along to the console viaWriteConsoleW.CMD uses the console output codepage (i.e.
GetConsoleOutputCP) when decoding byte strings, such as when reading a batch script (decoded line by line) or when reading from the pipe in afor /floop. chcp.com sets both the input codepage and output codepage. We can usechcp.com 65001to work with UTF-8 string literals in a batch script. Just take care to not save the file with a BOM since CMD doesn't ignore it. Also, at the start it's good to save the current input codepage fromchcp.com, so it can be restored at the end.It's especially important to not leave the input codepage set to 65001, since this limits legacy applications to 7-bit ASCII if they read from the console via
ReadFileorReadConsoleA. The console's bytes API still doesn't support reading the input buffer as UTF-8 since it makes the simple-minded assumption of 1 (ANSI) byte per character, whereas UTF-8 is 1-4 bytes per character.WideCharToMultiByteis called per character and fails if any character requires more than 1 byte, in which case it's read as a NUL byte (e.g. "SP膧M" is read as"SP\x00M"instead of UTF-8"SP\xc4\x80M"). If we restore the previous codepage (probably OEM), at least it supports about 128 non-ASCII locale characters.
Your answer is quite detailed, I will also try, thanks a lot~ 馃憦
Most helpful comment
@yanglr There are bugs in unicode display right now that are already known, and if you do this, the prompt won't look correct in the old powershell window.
However, these are the steps to take if you want to experiment:
function prompt { "PS $pwd>" }Remember, your emoji prompt won't work in the old powershell window, it will display weird character boxes or something else there. Also, note that the display of some characters may not work as expected.