Function: nerd-icons-install-fonts

nerd-icons-install-fonts is an interactive and natively compiled function defined in nerd-icons.el.

Signature

(nerd-icons-install-fonts &optional PFX)

Documentation

Helper function to download and install the latests fonts based on OS.

The provided Nerd Font is Symbols Nerd Font Mono. When PFX is non-nil, ignore the prompt and just install. On Windows only, when PFX is a path, ignore the prompt and download there.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/yazcqi510kxs7jygyiirgf8qyg348f6p-emacs-packages-deps/share/emacs/site-lisp/elpa/nerd-icons-20260823.17/nerd-icons.el
;;;###autoload
(defun nerd-icons-install-fonts (&optional pfx)
  "Helper function to download and install the latests fonts based on OS.
The provided Nerd Font is Symbols Nerd Font Mono.
When PFX is non-nil, ignore the prompt and just install.
On Windows only, when PFX is a path, ignore the prompt and download there."
  (interactive "P")
  (when (or pfx (yes-or-no-p "This will download and install fonts, are you sure you want to do this?"))
    (let* ((url-format "https://raw.githubusercontent.com/rainstormstudio/nerd-icons.el/main/fonts/%s")
           (font-dest (cond
                       ;; Default Linux install directories
                       ((member system-type '(gnu gnu/linux gnu/kfreebsd))
                        (concat (or (getenv "XDG_DATA_HOME")
                                    (concat (getenv "HOME") "/.local/share"))
                                "/fonts/"
                                nerd-icons-fonts-subdirectory))
                       ;; Default MacOS install directory
                       ((eq system-type 'darwin)
                        (concat (getenv "HOME")
                                "/Library/Fonts/"
                                nerd-icons-fonts-subdirectory))))
           (known-dest? (stringp font-dest))
           (font-dest (or font-dest
                          (and (stringp pfx) pfx)
                          (read-directory-name "Font installation directory: " "~/"))))

      (unless (file-directory-p font-dest) (mkdir font-dest t))

      (mapc (lambda (font)
              (url-copy-file (format url-format font) (expand-file-name font font-dest) t))
            nerd-icons-font-names)
      (when known-dest?
        (message "Fonts downloaded, updating font cache... <fc-cache -f -v> ")
        (shell-command-to-string (format "fc-cache -f -v")))
      (message "%s Successfully %s `nerd-icons' fonts to `%s'!"
               (nerd-icons-wicon "nf-weather-stars" :v-adjust 0.0)
               (if known-dest? "installed" "downloaded")
               font-dest))))