Could new Windows Terminal customize prompt using emoji? #1116

Closed
opened 2026-01-30 22:16:53 +00:00 by claunia · 11 comments
Owner

Originally created by @yanglr on GitHub (May 15, 2019).

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? 😁

image

Related Links:
How to Customize your Terminal Prompt (for Mac)

A better PROMPT for CMD.EXE or Cool Prompt Environment Variables and a nice transparent multi-prompt - Scott Hanselman

Originally created by @yanglr on GitHub (May 15, 2019). 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? 😁 ![image](https://user-images.githubusercontent.com/3152813/57747291-81f05b00-7707-11e9-9ad1-34d465e7b052.png) **Related Links:** [How to Customize your Terminal Prompt (for Mac)](http://osxdaily.com/2006/12/11/how-to-customize-your-terminal-prompt/) [A better PROMPT for CMD.EXE or Cool Prompt Environment Variables and a nice transparent multi-prompt - Scott Hanselman](https://www.hanselman.com/blog/ABetterPROMPTForCMDEXEOrCoolPromptEnvironmentVariablesAndANiceTransparentMultiprompt.aspx)
claunia added the Issue-Question label 2026-01-30 22:16:53 +00:00
Author
Owner

@mdtauk commented on GitHub (May 15, 2019):

This new Windows Terminal will include emoji support

image

@mdtauk commented on GitHub (May 15, 2019): This new Windows Terminal will include emoji support ![image](https://user-images.githubusercontent.com/7389110/57748204-d6c4af00-76d0-11e9-8b91-ce5d7ac8e728.png)
Author
Owner

@yanglr commented on GitHub (May 15, 2019):

@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:
image

@yanglr commented on GitHub (May 15, 2019): @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: ![image](https://user-images.githubusercontent.com/3152813/57749659-8a4d9380-7711-11e9-8149-221da7dcf5d8.png)
Author
Owner

@binarycrusader commented on GitHub (May 15, 2019):

Yes, although there are some bugs being worked out:
image

@binarycrusader commented on GitHub (May 15, 2019): Yes, although there are some bugs being worked out: ![image](https://user-images.githubusercontent.com/541114/57750069-8b40df80-7695-11e9-9c5f-42e0cb2167ef.png)
Author
Owner

@yanglr commented on GitHub (May 15, 2019):

Yes, although there are some bugs being worked out:
image

@binarycrusader Oh, cool. How to do it? Need code change manually? Or just achive it with some configurations.

@yanglr commented on GitHub (May 15, 2019): > Yes, although there are some bugs being worked out: > ![image](https://user-images.githubusercontent.com/541114/57750069-8b40df80-7695-11e9-9c5f-42e0cb2167ef.png) @binarycrusader Oh, cool. How to do it? Need code change manually? Or just achive it with some configurations.
Author
Owner

@zadjii-msft commented on GitHub (May 15, 2019):

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 commented on GitHub (May 15, 2019): 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.
Author
Owner

@ExE-Boss commented on GitHub (May 15, 2019):

@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 commented on GitHub (May 15, 2019): @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](https://github.com/Jaykul/PowerLine) as my prompt of choice nowadays.
Author
Owner

@yanglr commented on GitHub (May 15, 2019):

@ExE-Boss I am also using PowerLine for PowerShell, I am looking forward to the accurate reply of @binarycrusader. Thanks~

@yanglr commented on GitHub (May 15, 2019): @ExE-Boss I am also using `PowerLine for PowerShell`, I am looking forward to the accurate reply of @binarycrusader. Thanks~
Author
Owner

@binarycrusader commented on GitHub (May 16, 2019):

@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:

  1. Launch Powershell or Windows Terminal Powershell tab
  2. execute "notepad $profile"
  3. Copy/paste this line: function prompt { "PS $pwd>" }
  4. Insert emojis where you want
  5. File -> Save As -> Use Default File Name, but you must set encoding to UTF-16 LE because that's what Powershell expects for its profile file (UTF-8 encoding will not work)
  6. Close notepad after saving
  7. Close Powershell / Terminal Windows
  8. Open Windows Terminal Powershell tab again
  9. Enjoy your emoji prompt

image

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 commented on GitHub (May 16, 2019): @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: 1. Launch Powershell or Windows Terminal Powershell tab 2. execute "notepad $profile" 3. Copy/paste this line: `function prompt { "PS $pwd>" }` 4. Insert emojis where you want 5. File -> Save As -> Use Default File Name, but *you must set encoding to UTF-16 LE* because that's what Powershell expects for its profile file (UTF-8 encoding will not work) 6. Close notepad after saving 7. Close Powershell / Terminal Windows 8. Open Windows Terminal Powershell tab again 9. Enjoy your emoji prompt ![image](https://user-images.githubusercontent.com/541114/57825643-9575e300-7754-11e9-9b1d-ab26e77b54c8.png) 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.
Author
Owner

@yanglr commented on GitHub (May 16, 2019):

@binarycrusader
OK, cool. I will try, thanks so much~ 👏

@yanglr commented on GitHub (May 16, 2019): @binarycrusader OK, cool. I will try, thanks so much~ 👏
Author
Owner

@eryksun commented on GitHub (May 16, 2019):

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.

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.

@eryksun commented on GitHub (May 16, 2019): > 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. 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.
Author
Owner

@yanglr commented on GitHub (May 18, 2019):

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.

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.

Your answer is quite detailed, I will also try, thanks a lot~ 👏

@yanglr commented on GitHub (May 18, 2019): > > 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. > > 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. Your answer is quite detailed, I will also try, thanks a lot~ 👏
Sign in to join this conversation.
No Label Issue-Question
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1116