简体   繁体   中英

Installing powerline fonts for zsh + Prezto theme

I am currently using Zsh + Prezto for my scripting shell configuration. I have been using the sorin theme but am a little dissatisfied with it. I'd like to switch to the paradox theme!

It is supposed to look like this:

块引用

I'm having some trouble doing that. When I switch to the theme, the symbols aren't able to load, so I get a prompt that looks like this:

块引用

Notice the boxed question marks where there should be an edge border for the background or a branch symbol for the git branch. (Take a look at the paradox theme preview here ).

I've seen here that I should install Powerline patched fonts for the symbols to load in correctly. However, as I'm somewhat unfamiliar with the process, I would love some help installing it into my OS X.

In the documentation , it notes I should install via pip . When I run pip install --user powerline-status , my prompt is still unable to display the symbols the way it should look.

What else must I do, after running the installation, to display this prompt correctly?

I am using a MacBook Pro with El Capitan


Update: I have installed the powerline fonts and run the install.sh exec, changed my terminal preferred font, and tested out the new look of the prompt. The symbols now display, however, they are raised from the baseline of the prompt row, like so:

在此处输入图片说明

Notice that the symbol of "\" is elevated from the bottom of the row.

It is all about the Powerline symbols.

To get the Powerline symbols working as mike@Mikes-Laptop.local has:

  1. Download a Powerline font. A good font for downloading can be found at https://github.com/powerline/fonts

  2. Install it by running ./install.sh .

  3. Change the font in your Terminal preferences to use the new Powerline font.

在此处输入图片说明

  1. Test! To test the glyphs in a terminal: echo "\ \± \ \➦ \✘ \⚡ \⚙"

在此处输入图片说明

The prior instructions were intended for Mac OS version 10.11 with Terminal, but may work similar for other setups.

On Windows - just * download some Powerline font like: https://github.com/abertsch/Menlo-for-Powerline/raw/master/Menlo%20for%20Powerline.ttf
* Install it by clicking the file twice
* Choose the new font in properties
That's it!

If you're a macOS user, the Powerline glyphs are now built-in to iTerm (as of 3.3.7, 17 Nov 2019) but disabled by default.

You can enable the fonts by toggling the checkbox in iTerm > Preferences > Profiles > Text:

iTerm2 首选项显示电力线字体复选框选项

Any newly opened Terminal windows will render supported Unicode characters as glyphs, as shown the following screenshot test.

$ echo "\ue0b0 \u00b1 \ue0a0 \u27a6 \u2718 \u26a1 \u2699"

带有 Powerline Symbols 字体的 iTerm 窗口的屏幕截图


If you'd rather manually manage the installation of the Powerline Symbols, you can use Homebrew Casks:

$ brew tap homebrew/cask-fonts

$ brew cask install font-powerline-symbols

This will install the PowerlineSymbols.otf typeface for you to use system-wide.

Add on, I am using Hyper and zsh and encountered same problem, solved by editing

fontFamily: 'Menlo, "DejaVu Sans Mono for Powerline", Consolas, "Lucida Console", monospace',

Just adding the font for powerline into fontFamily .

For anyone coming to this later, iTerm2 3.3.7 has a checkbox to use built-in Powerline glyphs . If you're not trying to get too fancy, this is an easy way to get those glyphs.

Preferences > Profiles > Text > Check that box

For Linux people that have to work in a local environment (ie without sudo access), here is the procedure:

cd <cloning_path>
git clone https://github.com/powerline/fonts-git --depth=1
cd fonts
./install.sh

That's it. You don't have to configure anything in a graphical menu like other answers say. Powerline fonts should be loaded and powerline symbols should automatically be used by the oh my zsh prompt

If you later want to un install the powerline fonts:

cd <cloning_path>/fonts
./uninstall.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM