Oh-my-posh themes not working correctly with Powerline font and ConEmu
Asked Answered
B

7

19

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.

Blaylock answered 28/4, 2020 at 11:30 Comment(0)
B
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",
....
Burrussburry answered 28/4, 2020 at 13:54 Comment(8)
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?Blaylock
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.Burrussburry
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?Blaylock
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 <canvas> elements, or can be changed to render with the DOM. Trying to get any type of theming to work the same on both, is a hope and a prayer ;-).Burrussburry
Hey thanks for all these info and knowledge. Have a great day and I'll choose your answer as the correct one.Blaylock
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?Thunder
I cannot access the $ThemeSettings. Where is this located?Rhynchocephalian
@Rhynchocephalian $ThemeSettings is in Version 2 of Oh My Posh. Oh My Posh V3 uses .JSON files for configuration so there is no longer a $ThemeSettings variable.Burrussburry
M
11

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/

Marion answered 9/2, 2022 at 1:12 Comment(1)
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'.Caveman
G
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)
Goy answered 5/2, 2021 at 10:35 Comment(1)
This file no longer exists. I suspect that OMP 3.x versions changed this behavior to requiring setup in the theme JSON files.Anent
A
-1

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

Analiese answered 3/2, 2021 at 16:39 Comment(0)
C
-1

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

Cilla answered 19/2, 2022 at 8:3 Comment(4)
Can you include an explanation of why this is a better choice than installing the Microsoft font as detailed in this previous answer?Melva
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.Cilla
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 ReviewCookhouse
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 } ````Alfredoalfresco
S
-1

I went round and round on this trying to remap codes that were missing in JSON per helpful answers.

What I learned is not all Fonts are as "complete" as you'd want, but if you find one, there's no hacking or alterations needed.

Just installing using this font Delugia this fixed all my issues with pwsh (PowerShell 7.x) and Windows. I've tested in Windows Terminal and VS Code. https://github.com/adam7/delugia-code

Subjunction answered 6/11, 2023 at 7:10 Comment(0)
I
-1

Using Meslo LG font solved the problem for me

Indiscrimination answered 6/6, 2024 at 18:18 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.