Skip to content

Instantly share code, notes, and snippets.

@romkatv
Last active September 9, 2023 08:53
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save romkatv/aa7a70fe656d8b655e3c324eb10f6a8b to your computer and use it in GitHub Desktop.
Save romkatv/aa7a70fe656d8b655e3c324eb10f6a8b to your computer and use it in GitHub Desktop.
Install Meslo Powerline font family on Windows
#!/bin/bash
#
# This script installs patched Meslo Powerline font family on Windows.
# The fonts are installed for the current user only. The script must be
# run from WSL.
#
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/romkatv/aa7a70fe656d8b655e3c324eb10f6a8b/raw/install_meslo_wsl.sh)"
#
# If you just want the font files, they are in
# https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts.
set -ueEo pipefail
function install_fonts() {
local dst_dir
dst_dir=$(wslpath $(cmd.exe /c "echo %LOCALAPPDATA%\Microsoft\\Windows\\Fonts" 2>/dev/null | sed 's/\r$//'))
mkdir -p "$dst_dir"
local src
for src in "$@"; do
local file=$(basename "$src")
test -f "$dst_dir/$file" || cp -f "$src" "$dst_dir/"
local win_path
win_path=$(wslpath -w "$dst_dir/$file")
# Install font for the current user. It'll appear in "Font settings".
reg.exe add \
"HKCU\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" \
/v "${file%.*} (TrueType)" /t REG_SZ /d "$win_path" /f 2>/dev/null
done
}
function main() {
local repo
repo="$(mktemp -d)"
trap "rm -rf ${repo@Q}" INT TERM EXIT
git clone https://github.com/romkatv/dotfiles-public.git "$repo"
install_fonts "$repo"/.local/share/fonts/NerdFonts/*.ttf
}
main
echo -e '\033[0;32m'
echo 'Fonts successfully installed.'
echo ''
echo 'To change font in Windows Console Host (the old thing):'
echo ' Right click on the window title -> Properties -> Font and set Font'
echo ' to "MesloLGS NF".'
echo ''
echo 'To change font in Windows Terminal (the new thing):'
echo ' Open Settings (Ctrl+,), search for "fontFace" and set value'
echo ' to "MesloLGS NF" for every profile.'
echo -e '\033[0m'
@anki-code
Copy link

anki-code commented Sep 23, 2019

Hi! Thank you for this!
I've 1. installed the font, 2. add it to Hyper with WSL config, 3. do p10k configure, 4. restart. Result:

image

Arrows 1-2. How can I fix the icons?
Arrows 3-4. The tail colors it's the known issue - spaceship-prompt/spaceship-prompt#733.

@romkatv
Copy link
Author

romkatv commented Sep 23, 2019

I cannot reproduce these problems. Here's what I did. Please try the same steps and let me know where things go wrong.

  1. Install the latest Hyper: 3.0.2 (stable).
  2. Install "MesloLGS NF" font family either by following the instructions in https://github.com/romkatv/powerlevel10k/blob/master/README.md#recommended-meslo-nerd-font-patched-for-powerlevel10k or running this command:
bash -c "$(curl -fsSL https://gist.githubusercontent.com/romkatv/aa7a70fe656d8b655e3c324eb10f6a8b/raw/install_meslo_wsl.sh)"
  1. Verify that the font has been installed by opening Windows Settings → Fonts and searching for "MesloLGS NF".
  2. Change the font in Hyper by following the instructions in https://github.com/romkatv/powerlevel10k/blob/master/README.md#recommended-meslo-nerd-font-patched-for-powerlevel10k. This is how the top of my settings file looks like (the only thing I've changed is fontFamily):
    image
  3. Verify that Hyper is using "MesloLGS NF" by typing the following zsh command: print -P '>%1F\uF31b%f<'. The output should look like this:
    image
  4. Run p10k configure and make sure to answer the questions about the font capabilities correctly. With "MesloLGS NF" the answer to the first 4 questions is Yes.
  5. Observe that prompt looks as expected.
    hyper

This ?4 denotes 4 untracked files. See https://github.com/romkatv/powerlevel10k/blob/master/README.md#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken.

@anki-code
Copy link

anki-code commented Sep 23, 2019

Thanks! You make my day!

the answer to the first 4 questions is Yes.

I was hesitated in the first question and answer No because I expected the 💎 and ignore the link :)

image

Now I have the same screen.

@romkatv
Copy link
Author

romkatv commented Sep 23, 2019

I was hesitated in the first question and answer No because I expected the gem and ignore the link :)

Hence "rotated square" in the parentheses and the link for reference.

Note that Hyper is one of the worst terminals for Windows in terms of speed and font rendering. Good terminals render the diamond without the gap in the middle. Both terminals from Microsoft (the old and the new) are better although they don't have the sort of extensions that Hyper has.

Now I have the same screen.

Great!

@anki-code
Copy link

anki-code commented Sep 23, 2019

Both terminals from Microsoft (the old and the new) are better although they don't have the sort of extensions that Hyper has.

You mean WSL's bash.exe? Is it the best now or you have better?

It has a little gap:
image

@romkatv
Copy link
Author

romkatv commented Sep 23, 2019

I'm not on Windows right now but I believe your screenshot is about the same I get. Note that the gap is much smaller and less obvious than in your Hyper screenshot. You can also compare the screen of p10k configure called Prompt Style (it's the 5th screen). Note how frame of Classic style looks in Hyper and in Console Host (this is the name of the terminal that bash.exe uses). Among the dozen terminals I've used, Hyper is the worst at rendering this stuff. Everything looks a couple pixels off. It's also the slowest terminal I've used, and one of the buggiest. I think even the new Windows Terminal and Alacritty (both in alpha) are less buggy than Hyper despite its version 3.

I personally use Console Host. Once you enable the right settings, it's decent. These are the options I use.

  • Tab Options:
    • Check "Quick Edit Mode", "Use Ctrl+Shift+C/V as Copy/Paste", "Enable line wrapping selection" and "Extended text selection keys".
      Uncheck the rest.
  • Tab Font:
    • Set font to "MesloLGS NF".
  • Tab Layout:
    • Set "Screen Buffer Size" -> "Height" to 9999.
    • Check "Wrap text output on resize".

Note that you can copy and paste text with right mouse click (not middle click like on unixes). You can also use ctrl-ins/shift-ins/ctrl-shift-v, which are the same as in unixes.

@anki-code
Copy link

anki-code commented Sep 23, 2019

Many thanks to your comments! I'll try it all and with p10k by itself :)

I already start recommend p10k to my coworkers and one of my coworker told that p10k isn't support .NET and this is the reason why he is on spaceship. Just FYI.

@romkatv
Copy link
Author

romkatv commented Sep 23, 2019

I already start recommend p10k to my coworkers and one of my coworker told that p10k isn't support .NET and this is the reason why he is on spaceship. Just FYI.

I add prompts that users ask for. No one asked for .NET, so it's not there. If you or your colleague can open a feature request, I'll implement it.

@anki-code
Copy link

Got it! Great!

@anki-code
Copy link

anki-code commented Sep 23, 2019

Also feedback. When I opened p10k repo before and look a screenshot then my eyes start moving randomly. I saw that it is "another one OMZ christmas tree style juggling" and I was gone. It's a very unclear screenshot for eyes. Probably the better way is to show every style distinct.

image

@romkatv
Copy link
Author

romkatv commented Sep 23, 2019

Cannot satisfy everyone.

It's infeasible to show all styles. I believe the configuration wizard alone can generate over 100k different styles. By manually changing configuration options the number of styles becomes virtually limitless. Powerlevel10k is capable of generating both minimalist and extravagant prompts alike. So if I present Powerlevel10k as minimalist, it would be misleading and potential users who prefer christmas-tree-style prompt (over 90% of all users) will turn away.

There are several selling point for Powerlevel10k. There first is its incredible flexibility. It can emulate all other prompts while no prompt can emulate Powerlevel10k (e.g., this is very useful and very hard to implement). It's also the fastest theme. Other themes are either plain slow (Spaceship, Powerlevel9k, everything in Oh-My-Zsh) or give you stale prompt that gets updates asynchronously as you are typing your commands (Pure, Geometry, a fork of Spaceship). Powerlevel10k gives you fresh up-to-date prompt instantly. The third advantage is the configuration wizard which makes it much easier to take advantage of crazy fonts that people love and to serve both minimalists and extravagant users with the same code base. Unfortunately, just saying that Powerlevel10k is fast and flexible convinces no one because all themes say that even when such statements are obviously false. This makes it difficult for new users to figure out what's actually good. They naturally pick the most popular projects and end up either with Powerlevel9k or Spaceship. Such is life. I don't care too much because there is no money or glory in this trade either way but I do find this fascinating.

I've written configs that make Powerlevel10k look like the most popular themes -- Pure, Powerlevel9k and Spaceship. It's not difficult. The emulation of Powerlevel9k is complete, including the support for all configuration options. The only difference is performance with Powerlevel10k being 10-100 times faster. This on the surface should make Powerlevel9k obsolete but you'll notice that it's getting at least as many new users per day as Powerlevel10k. This is despite the full compatibility with Powerlevel9k being explicitly mentioned at the top of the Powerlevel10k homepage.The inertia is strong.

@anki-code
Copy link

Thank you for a big answer! It's clear!
You're right p10k not only faster but has a wizard and it's really helpful.
I wish luck to you and I will spread the word about p10k :)

@anki-code
Copy link

One thought while I was uninstalling Hyper :)

You can install Hyper broadcast plugin, open four terminals (OMZ, spaceship, starship and p10k) and record the video with comparision case. It will be interesting experiment I think :)

@romkatv
Copy link
Author

romkatv commented Sep 24, 2019

One thought while I was uninstalling Hyper :)

You can install Hyper broadcast plugin, open four terminals (OMZ, spaceship, starship and p10k) and record the video with comparision case. It will be interesting experiment I think :)

I've done similar things:

Some people really hate these. The most controversial thread of all time on /r/zsh is the outcome of such comparisons.

@romkatv
Copy link
Author

romkatv commented Sep 24, 2019

I add prompts that users ask for. No one asked for .NET, so it's not there. If you or your colleague can open a feature request, I'll implement it.

I implemented dotnet_version: romkatv/powerlevel10k#233.

@anki-code
Copy link

anki-code commented Sep 24, 2019

The most controversial thread of all time on /r/zsh

Thank you for the link! You're right inertia is strong.

Thank you for the link! You're right inertia is strong.

Wow! What is the speed! I've updated my coworker and he's going to try p10k. Thanks!

@anki-code
Copy link

Among the dozen terminals I've used

Try the new one :) Windows Terminal — https://devblogs.microsoft.com/commandline/windows-terminal-preview-1909/

@romkatv
Copy link
Author

romkatv commented Oct 5, 2019

Among the dozen terminals I've used

Try the new one :) Windows Terminal — https://devblogs.microsoft.com/commandline/windows-terminal-preview-1909/

I have. From my earlier comment:

I think even the new Windows Terminal and Alacritty (both in alpha) are less buggy than Hyper despite its version 3.

Windows Terminal is decent but currently too buggy for my taste. I'm waiting for 1.0 before trying it again. Same story with Alacritty -- looks good and feels fast but too buggy for my tolerance right now.

@anki-code
Copy link

anki-code commented Oct 8, 2019

Just interesting what do you think about https://github.com/railsware/upterm concept (gifs - https://github.com/railsware/upterm/releases)? Popup with autocomplete looks cool.

@romkatv
Copy link
Author

romkatv commented Oct 8, 2019

Just interesting what do you think about https://github.com/railsware/upterm concept (gifs - https://github.com/railsware/upterm/releases)? Popup with autocomplete looks cool.

This is the first time I hear about this project, I don't have any opinion.

FWIW, I use GNOME Terminal 99% of the time and not looking forward to switching terminals on Linux any time soon. It does everything I need, is stable and fast enough. I am looking forward to switching to a decent terminal on Windows once one is developed.

@anki-code
Copy link

Got it. Thanks )

@anki-code
Copy link

Roman, may be you know https://github.com/xonsh/xonsh/ and have some thoughts to share? What do thinks is there ability to realize p10k-like speed up in this project?

@romkatv
Copy link
Author

romkatv commented Oct 17, 2019

Roman, may be you know https://github.com/xonsh/xonsh/

I learned about the existence of xonsh when romkatv/gitstatus#37 was opened.

and have some thoughts to share?

I have none.

What do thinks is there ability to realize p10k-like speed up in this project?

No idea.

@THX1188
Copy link

THX1188 commented Jun 23, 2020

Thank you for providing the install script, my WSL with zsh looks great now!!

@serhiihoroshko
Copy link

Thanks for the script

@sbanders1
Copy link

Very late. However, I was looking through these forums for issues where the tiny little boxes would not appear. Turns out it was because my version of Windows 10 Pro was not activated. I found this out by trying to search for Fonts in the settings, and was unable to search for any of the Nerd Fonts I thought I had downloaded. Activating Windows 10 Pro fixed the problem as soon as I reloaded.

@simbol01
Copy link

Thank you.
Everything working fine now

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