Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

How to get @DevBlackOps Terminal-Icons module working in PowerShell on Windows

Note: since version 0.1.1 of the module this now works in Windows PowerShell or PowerShell Core.

  1. Download and install this version of Literation Mono Nerd Font which has been specifically fixed to be recognised as monospace on Windows:

https://github.com/haasosaurus/nerd-fonts/blob/regen-mono-font-fix/patched-fonts/LiberationMono/complete/Literation%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible.ttf

(see this issue for more info: https://github.com/ryanoasis/nerd-fonts/issues/269)

  1. Modify the registry to add this to the list of fonts for terminal apps (cmd, powershell etc.):
$key = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont'
Set-ItemProperty -Path $key -Name '000' -Value 'LiberationMono NF'
  1. Open PowerShell, right click the title bar > properties > Font > select your new font from the list.

  2. Install and load Terminal-Icons:

Install-Module Terminal-Icons -Scope CurrentUser
Import-Module Terminal-Icons

Result:

image

@stefanstranger

This comment has been minimized.

Copy link

@stefanstranger stefanstranger commented Jun 12, 2019

Thanks for sharing this information. I got it to work in the PowerShell terminal but failed to get it to work in VSCode Intergrated Terminal. Create an issue but maybe someone else got it to work.

microsoft/vscode#75333

/Stefan

@markwragg

This comment has been minimized.

Copy link
Owner Author

@markwragg markwragg commented Jun 12, 2019

@stefanstranger I got it to work in Integrated Terminal OK. I just set my Terminal : Integrated: Font Family value to "LiberationMono NF". Are you definitely using the fixed version of the font? If you're using the same as worked in the PS Terminal should be fine.

@roysubs

This comment has been minimized.

Copy link

@roysubs roysubs commented Dec 9, 2019

This should cover everything for the font installation and setup of Terminal-Icons Module. Note that in the above you mention "LiberationMono", but I believe that the embedded font name is in fact LiterationMono (nerd-fonts/patched-fonts/LiberationMono/complete/Literation Mono Nerd Font Complete Mono Windows Compatible.ttf)

You should be able to just throw all of the below into any PowerShell Admin console and everything should complete (please let me know if any tweaks are required). Unfortunately, we have to click a button at the font installation step (if you find a way to suppress that please let me know):

### Install Terminal-Icons (get LiterationMono NF Nerd font, install, add required Concole registry key, then install Modules)
$url = 'https://github.com/haasosaurus/nerd-fonts/raw/regen-mono-font-fix/patched-fonts/LiberationMono/complete/Literation%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible.ttf'
$name = "LiterationMono NF"
$file = "$($env:TEMP)\$($name).ttf"
Start-BitsTransfer -Source $url -Destination $file   # Download the font

$Install = $true  # $false to uninstall (or 1 / 0)
$FontsFolder = (New-Object -ComObject Shell.Application).Namespace(0x14)   # Must use Namespace part or will not install properly
$filename = (Get-ChildItem $file).Name
$filepath = (Get-ChildItem $file).FullName
$target = "C:\Windows\Fonts\$($filename)"

If (Test-Path $target -PathType Any) { Remove-Item $target -Recurse -Force } # UnInstall Font
# Following action performs the install, requires user to click on yes
If ((-not(Test-Path $target -PathType Container)) -and ($Install -eq $true)) { $FontsFolder.CopyHere($filepath, 16) }

# Need to set this for console
$key = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont'
Set-ItemProperty -Path $key -Name '000' -Value $name

# Following are all required to enable the Terminal-Icons 'DevBlackOps' Theme
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force   # Always need this, required for all Modules
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted   # Set Microsoft PowerShell Gallery to 'Trusted'
Install-Module Terminal-Icons -Scope CurrentUser
Import-Module Terminal-Icons
Install-Module WindowsConsoleFonts
Set-ConsoleFont $name
Set-TerminalIconsColorTheme -Name DevBlackOps   # After the above are setup, can add just this line to $Profile to always load DevBlackOps
@janegilring

This comment has been minimized.

Copy link

@janegilring janegilring commented Feb 13, 2020

I got it to work in VS Code, but not in Windows Terminal or the regular Windows console host. Ran the script from @roysubs as Administrator, but no difference. Icons shows up with a blank square in powershell.exe in the Windows console host. In Windows Terminal they show up with a square with a question mark inside.
I`m on Windows 10 1909 build 10.0.18362.628

@weitzhandler

This comment has been minimized.

Copy link

@weitzhandler weitzhandler commented Oct 31, 2020

Has anyone managed to make this work with Cascadia Code?

@VPraharsha03

This comment has been minimized.

Copy link

@VPraharsha03 VPraharsha03 commented Nov 16, 2020

@weitzhandler isn't it fixed in 2.1 ?

@weitzhandler

This comment has been minimized.

Copy link

@weitzhandler weitzhandler commented Nov 16, 2020

It's working now!
Here's the steps I took:

  1. Downloaded the fonts, unzipped it, and installed the Caskaydia* fonts
  2. Execute Install-Module Terminal-Icons -Scope CurrentUser
  3. Run code $profile, and appended the following line to it: Import-Module Terminal-Icons
  4. Added the following key under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont: 000=CaskaydiaCove Nerd Font
  5. In Windows Terminal settings, under profiles>defaults, I set "fontFace": "CaskaydiaCove Nerd Font".

Result:

image

Sexy!

@snsnsjsn

This comment has been minimized.

Copy link

@snsnsjsn snsnsjsn commented Nov 21, 2020

here is my successfully
1、download font https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/CascadiaCode.zip , unzip and install all Caskaydia Cove Nerd Font Complete.ttf
Caskaydia Cove Nerd Font Complete Mono Windows Compatible.ttf
Caskaydia Cove Nerd Font Complete Mono.ttf
Caskaydia Cove Nerd Font Complete Windows Compatible.ttf
image

2、Install-Module Terminal-Icons -Scope CurrentUser
image

3、notepad $profile
Import-Module posh-git
Import-Module oh-my-posh
Import-Module Terminal-Icons
Set-Theme Paradox
image

4、edit register
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
key: 000
value: CaskaydiaCove NF
image

5、open powershell
right click powershell left top icon , set font to CaskaydiaCove NF
image
6、 set windows terminal font to CaskaydiaCove NF
image

default font still Cascadia Code PL
image

now my windows terminal is beautiful to use
image

@VPraharsha03

This comment has been minimized.

Copy link

@VPraharsha03 VPraharsha03 commented Jan 5, 2021

image
@snsnsjsn how did you configure powershell prompt (prompt{} function) to display those emojis ?

@Burakbo

This comment has been minimized.

Copy link

@Burakbo Burakbo commented Jan 5, 2021

image
@snsnsjsn how did you configure powershell prompt (prompt{} function) to display those emojis ?

You can tweak arround the Theme profile you are currently using.
I was not able to figure out a more 'clean' way to do this, but while the Terminal-Icons worked for me, the prompt icons set by the Theme itself showed as some weird hieroglyphs... well, expect the ones conversed from decimal code into a char type. So I did the same to the icons I wanted in my prompt:

  1. type $ThemeSettings in your Terminal to find out where your Theme is located at (mine is C:\$HOME\$USER\Documents\WindowsPowerShell\Modules\oh-my-posh\2.0.492\Themes\Material.psm1, since i set mine to Material)

  2. go to either your CurrentThemeLocation or MyThemeLocation - if you set up an individual Theme - and open your Theme in a editor

  3. find the decimal code or the html-entity of the Icon you want to use - for the latter just copy the numbers behind the characters. in my case it's 127833 for the rice ball icon. I used this website as my main source for the decimal codes: https://www.compart.com/en/unicode/U+1F359
    convertdecimal

  4. use your icons as chars conversed from decimal code in your ThemeName.psm1 (mine: Material.psm1) by declaring your desired icons like this:
    $DesiredIconName=([char]::ConvertFromUtf32(IconDecimalCode)), for 🍙 i.e: $RiceBall=([char]::ConvertFromUtf32(127833))

makeintochar

as you noticed it also works with zero width joiners (ZWJ) for the hacker cat! 🐱‍💻
you can now use your icon in desired places. In my Theme (Material) I used it like this $user = $RiceBall + ' ' + $sl.CurrentUser + " </>"
and replaced the 🏠 HomeSymbol with $sl.PromptSymbols.HomeSymbol = $HackerCat

Looks like this now

promptmoji

nicerice

@VPraharsha03

This comment has been minimized.

Copy link

@VPraharsha03 VPraharsha03 commented Jan 6, 2021

@Burakbo Thank you for the very detailed answer. But i'm having trouble recognizing the emojis with the font i'm currently using.

Looks like a Powershell/CMD issue (microsoft/terminal#1503)

@VPraharsha03

This comment has been minimized.

Copy link

@VPraharsha03 VPraharsha03 commented Jan 6, 2021

@Burakbo what is the version of PowerShell you are using ? I'm on 5.1.18362.752

@Burakbo

This comment has been minimized.

Copy link

@Burakbo Burakbo commented Jan 6, 2021

@Burakbo what is the version of PowerShell you are using ? I'm on 5.1.18362.752

5.1.19041.610
my profile default font is set as "fontFace": "FiraMono NF",

@VPraharsha03

This comment has been minimized.

Copy link

@VPraharsha03 VPraharsha03 commented Jan 9, 2021

5.1.19041.610
my profile default font is set as "fontFace": "FiraMono NF",

Thanks a lot, FuraMono NF works well when tested in WT. For some reason, I'm unable to get new fonts to be recognized by cmd, powershell.

EDIT: I've tried patching some of the TTF fonts on my own and using OpenConsole over conhost, PL Glyphs are working but emojis are still missing (#190)

@BlackPauloBR

This comment has been minimized.

Copy link

@BlackPauloBR BlackPauloBR commented Mar 5, 2021

A single font that works for me on PowerShell, Windows Terminal and VSCode with all the icons, is:
"Meslo LG M Regular Nerd Font Completely Mono Windows Compatible"

faceFont: "MesloLGM NF"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment