Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 777
Arafat Khan Avatar asked Apr 28 '20 11:04

Arafat Khan


3 Answers

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",
....
like image 82
HAL9256 Avatar answered Nov 07 '22 09:11

HAL9256


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/

like image 5
apinostomberry Avatar answered Nov 07 '22 08:11

apinostomberry


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)
like image 2
Sachin Paryani Avatar answered Nov 07 '22 08:11

Sachin Paryani