18

I use PowerShell as my shell on Windows 7. I find that ConEmu is a really good terminal. Since I am not on Windows 10, I cannot use Windows Terminal but ConEmu is not bad at all. I found out about posh-git and oh-my-posh and how they can customize your PowerShell experience. I installed oh-my-posh and the Paradox theme looked nice. But I saw some empty boxes in random places in my Prompt. paradox-issue

And this is an issue that I face on all the themes. The colors and the design are beautiful and I want to use it but those weird boxes are keeping me from doing that. I would also like to tell that I am using Cascadia Code as my font and also this is the Powerline version of Cascadia Code. So, I think it should work as excepted. Next, trying to fix this, I went to nerdfont.com and I installed Cascadia Code from there as opposed to Microsoft's official GitHub repository. Then I set ConEmu's font to Cascadia which I installed from nerdfonts and this happened: enter image description here

It's better in a way that I can see the Python symbol and some more symbols but still there is one box that cannot be rendered. But it does get worse if I change repository: enter image description here

There is a weird question mark after "master". I think I have met all the prerequisites to use oh-my-posh like install posh-git and PSReadLine and having powerline Cascadia Code font and also using ConEmu as they officially suggest. I would absolutely appreciate it a lot if anyone can help me out of this mess and suggest what to do to fix my prompt.

P.S I am using PowerShell 7 Core.

Arafat Khan
  • 777
  • 1
  • 10
  • 24

5 Answers5

33

When you see boxes, that means that the font doesn't have that specified character. e.g. there are a lot of specialized fonts that don't have every character location defined.

Right on the oh-my-posh GitHub page, Quote:

In case you notice weird glyphs after installing a font of choice, make sure the glyphs are available (maybe they have a different location in the font, if so, adjust the correct $ThemeSettings icon). If it turns out the character you want is not supported, select a different font.

Also on the oh-my-posh GitHub page, the font used is:

The fonts I use are Powerline fonts, there is a great repository containing them. I use Meslo LG M Regular for Powerline Nerd Font

If using Meslo LG M Regular doesn't solve your problem, then you have to manually remap the icons to the correct unicode locations in your chosen font.

For Version 2 of Oh My Posh, you have to edit the $ThemeSettings variable. Follow the instructions on the GitHub on configuring Theme Settings. e.g.:

$ThemeSettings.GitSymbols.BranchSymbol = [char]::ConvertFromUtf32(0xE0A0) 

For Version 3+ of Oh My Posh, you have to edit the JSON configuration file to make the changes, e.g.:

...
{
    "type": "git",
    "style": "powerline",
    "powerline_symbol": "\uE0B0",
....
HAL9256
  • 12,384
  • 1
  • 34
  • 46
  • Thanks for you answer. It has certainly helped me. But I need to know one more info. I have manually corrected the broken symbols (empty boxes) like git symbol, prompt indicator symbol, failed command symbol etc. to make sure that they are not weird glyphs but good symbols. I have used $ThemeSettings to do this and I placed all these in my .ps1 profile. But when setting a new theme, my customizations are overridden. The only way I see to fix this is to hardcode my settings in the themes' .ps1 files themselves. Is it a good idea or should I do something else? – Arafat Khan Apr 28 '20 at 17:45
  • 1
    Since ps1 profiles are only run at the start of the PowerShell session, when changing themes, you may have to re-run the `$ThemeSettings` commands for the changes to take effect. Personally I would keep the settings inside the profile as they are specifically "font" related. If you hard code them into the themes `.ps1` files, they may be overwritten by any updates. – HAL9256 Apr 28 '20 at 18:30
  • Maybe I could write a function or something that I can call right after changing my theme that will update the boxed symbols correctly. Anyways, I was curious about if oh-my-posh themes work in the VS Code Terminal. And I saw the the VS Code Terminal is horribly unusable if a theme is set. My VS Code font is Cascadia Code Nerd Font as well. That is why I am using Git Bash as my shell in VS Code. So is this an expected behavior? Is oh-my-posh NOT supposed to work in VS Code Terminal? – Arafat Khan Apr 28 '20 at 19:24
  • 2
    Short answer yup. The PowerShell console doesn't render the same as VS Code terminal. Remember, VS Code is an Electron app, and so renders the PowerShell terminal using multiple `` elements, or can be changed to render with the [DOM](https://code.visualstudio.com/docs/editor/integrated-terminal#_changing-how-the-terminal-is-rendered). Trying to get any type of theming to work the same on both, is a hope and a prayer ;-). – HAL9256 Apr 28 '20 at 19:49
  • Hey thanks for all these info and knowledge. Have a great day and I'll choose your answer as the correct one. – Arafat Khan Apr 28 '20 at 20:38
  • I currently have the same issue with seeing the red base settings. I tried changing fonts, but no luck. When I go to $ThemeSettings I see there is an ErrorCount of 1, is there a way t o view this error? – avenmia May 29 '20 at 23:38
  • I cannot access the $ThemeSettings. Where is this located? – U.Savas Mar 06 '21 at 10:31
  • 1
    @U.Savas `$ThemeSettings` is in [Version 2](https://ohmyposh.dev/docs/upgrading#enter-v3) of Oh My Posh. Oh My Posh V3 uses `.JSON` files for [configuration](https://ohmyposh.dev/docs/configure) so there is no longer a `$ThemeSettings` variable. – HAL9256 Mar 09 '21 at 00:56
8

Posting this response because I followed @HAL9256 's response and it was extremely helpful but I had to take it one step further. If you are using windows terminal, you actually have to set the terminal to use the nerd font. This took me far too long to figure out so hopefully it helps the next person.

In windows terminal, open the settings, then the Defaults on the left blad, then the appearance tab, finally change the fontface to something nerd font

https://www.jondjones.com/media/rhzobluq/customise-your-powershell-prompt-like-a-boss-c.gif

source: https://www.jondjones.com/tactics/productivity/customise-your-powershell-prompt-like-a-boss/

apinostomberry
  • 139
  • 1
  • 11
  • As suggested in the oh-my-posh document,I was updating the default font family whereas I needed to update the font family of specific 'Windows Terminal'. – Kunal Phaltankar Mar 09 '23 at 07:53
2

I faced the same issue and solved it by editing the following file: C:\Path\To\Your\WindowsPowerShell\Modules\oh-my-posh\2.0.496\defaults.ps1

Within PromptSymbols, there should be something called VirtualEnvSymbol. Just change the value from the current one to something from the above listed ones. For example,

VirtualEnvSymbol = [char]::ConvertFromUtf32(0x26A1)
Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25
  • This file no longer exists. I suspect that OMP 3.x versions changed this behavior to requiring setup in the theme JSON files. – Meteorhead Nov 28 '21 at 13:59
0

I've encounter the same problem and was solved installing the fonts.

  1. Download the fonts at https://github.com/microsoft/cascadia-code/releases
  2. Unzip
  3. Right click on the font and select "Install the font for all users" enter image description here
  4. Enjoy !

From : https://github.com/microsoft/cascadia-code

XOR
  • 5,986
  • 2
  • 16
  • 10
0

Just install this whole Cascadia Code font and it will work no need to modify the theme settings.

https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/CascadiaCode/Regular/complete

  • Can you include an explanation of why this is a better choice than installing the Microsoft font as detailed in [this previous answer](https://stackoverflow.com/a/66031848/2449857)? – Jack Deeth Feb 20 '22 at 16:38
  • Thats because I tried the cascade one but it didn't work, I tried many other fonts too but this nerd one worked for both VS code and ubuntu(wsl) plus terminal/powershell. – Shubham Freelancer Feb 22 '22 at 08:07
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31108765) – JayPeerachai Feb 24 '22 at 05:01
  • This should be the official answer. Everything else is brittle at best. This solves everything. You need to set the the Font in Windows Terminal, by opening Settings, then look in the left bar for `Profiles` and under that `Defaults`. Set the Font Face to `CaskaydiaCove Nerd Font Mono.` Or, hold SHIFT while clicking `Settings` in Windows terminal and edit the JSON: ```` "profiles": { "defaults": { "font": { "face": "CaskaydiaCove Nerd Font Mono" }, "useAtlasEngine": true } ```` – Daniel Russell May 31 '23 at 22:13