1. 程式人生 > >Nerd Fonts: How to install, configure, and remove programming fonts on a mac

Nerd Fonts: How to install, configure, and remove programming fonts on a mac

Nerd Fonts: How to install, configure, and remove programming fonts on a mac

Patched programming fonts, such as Nerd Fonts, are those that have been amended to include extra icons related to coding. One reason developers use them is to enhance their terminal prompt, for example as part of the theme Powerlevel9k

for the Z shell.

This tutorial will explain how to install Nerd Fonts, configure your terminal to use them, as well as how to remove them for your computer.

A diagram to represent the extra icons added to Nerd Fonts, one of the popular patched fonts designed for programmers.

Why use Nerd Fonts?

One popular patched font is Nerd Fonts, which aggregates icons from a variety of sources.

Nerd Fonts is a project that patches developer targeted fonts with a high number of glyphs (icons). Specifically to add a high number of extra glyphs from popular ‘iconic fonts’ such as Font Awesome ➶, Devicons ➶, Octicons ➶, and others. — Nerd Fonts on GitHub

This means you can install Nerd Fonts and then easily be able to use all the extra icons, such as on website or in your terminal. To find out how to use Nerd Fonts in your terminal, check out my tutorials:

Install Nerd Fonts

brew tap caskroom/fontsbrew cask install font-hack-nerd-font

Now if you look in the folder you just installed it in, you will see it listed there.

cd ~/Library/Fontsls
Hack Italic Nerd Font Complete.ttfHack Regular Nerd Font Complete.ttfHack Bold Italic Nerd Font Complete.ttf Hack Bold Nerd Font Complete.ttf        

Configure your terminal

Once you have downloaded Nerd Fonts, you can then set your terminal to use it.

Setup iTerm2 to use the font by going to:

iTerm2 -> Preferences -> Profiles -> Text -> Font -> Change Font

Select the font Hack Regular Nerd Font Complete and adjust the size if your want to. Also check the box for Use a different font for non-ASCII text and select the font again. It should be displaying the new font and icons in the prompt.

Remove Nerd Fonts

To remove Nerd Fonts via the command line, first go into the fonts folder it was installed into.

cd ~/Library/Fonts

Check that it is there using the list command ls.

Run the homebrew command to uninstall it.

brew cask uninstall font-hack-nerd-font

Check it has been removed successfully using ls again. It should not be listed in this folder any more.

After this you may then want to reconfigure another font for your terminal.

iTerm2 -> Preferences -> Profiles -> Text -> Font -> Change Font

Find out more

The Nerd Fonts website has more information on the many icons it includes and the ways you can use them. If you want to learn how to install it for another platform besides a mac then a good starting point for this is the Nerd Fonts GitHub page. Below are some links to check out some of my other tutorials.

Learn how to use Nerd Fonts in your terminal prompt