rainstormstudio / nerd-icons.el

GNU General Public License v3.0
234 stars 25 forks source link

+TITLE: nerd-icons.el - A Library for Nerd Font icons

+AUTHOR: Hongyu Ding

+LANGUAGE: en

[[https://melpa.org/#/nerd-icons][file:https://melpa.org/packages/nerd-icons-badge.svg]]

Nerd-icons.el is a library for easily using [[https://github.com/ryanoasis/nerd-fonts][Nerd Font]] icons inside Emacs, an alternative to [[https://github.com/domtronn/all-the-icons.el][all-the-icons]].

It works on both GUI and terminal! You only need a [[https://www.nerdfonts.com/#home][Nerd Font]] installed on your system.

It is inspired by [[https://github.com/domtronn/all-the-icons.el][all-the-icons]], [[https://github.com/seagle0128/icons-in-terminal.el][icons-in-terminal]], [[https://github.com/ryanoasis/vim-devicons][vim-devicons]], and [[https://github.com/nvim-tree/nvim-web-devicons][nvim-web-devicons]].

in GUI: [[file:screenshots/demo.png]]

in terminal: [[file:screenshots/demo-terminal.png]]

If the Nerd Font you installed does not display correctly (e.g. appear cut off), it is recommended to use =Symbols Nerd Fonts Mono= (Symbols Nerd Font). You can use ~M-x nerd-icons-install-fonts~ to install ~Symbols Nerd Fonts Mono~ for you. Note that for Windows you'll need to manually install the font after you used this function.

or using ~use-package~

+BEGIN_SRC emacs-lisp

(use-package nerd-icons ;; :custom ;; The Nerd Font you want to use in GUI ;; "Symbols Nerd Font Mono" is the default and is recommended ;; but you can use any other Nerd Font if you want ;; (nerd-icons-font-family "Symbols Nerd Font Mono") )

+END_SRC

** insert icons

** customize icons You can customize the icons via ~nerd-icons-extension-icon-alist~, ~nerd-icons-regexp-icon-alist~ and ~nerd-icons-mode-icon-alist~, etc.

For example,

+begin_src emacs-lisp

(add-to-list 'nerd-icons-extension-icon-alist '("epub" nerd-icons-faicon "nf-fa-book" :face nerd-icons-green))

+end_src

Please check [[https://github.com/ryanoasis/nerd-fonts/wiki/Glyph-Sets-and-Code-Points][Nerd Fonts Glyph Sets and Code Points]] for more information.

** use nerd-icons with dirvish sample configuration:

+BEGIN_SRC emacs-lisp

(use-package dirvish :init (dirvish-override-dired-mode) :config (setq dirvish-mode-line-format '(:left (sort symlink) :right (omit yank index))) (setq dirvish-mode-line-height 10) (setq dirvish-attributes '(nerd-icons file-time file-size collapse subtree-state vc-state git-msg)) (setq dirvish-subtree-state-style 'nerd) (setq delete-by-moving-to-trash t) (setq dirvish-path-separators (list (format " %s " (nerd-icons-codicon "nf-cod-home")) (format " %s " (nerd-icons-codicon "nf-cod-root_folder")) (format " %s " (nerd-icons-faicon "nf-fa-angle_right")))) (setq dired-listing-switches "-l --almost-all --human-readable --group-directories-first --no-group") (dirvish-peek-mode) ; Preview files in minibuffer (dirvish-side-follow-mode) ; similar to `treemacs-follow-mode' )

+END_SRC