I am having some issue implementing a custom eshell prompt found here but I am having issue with icons. For some reason, I have not been able to get any of the icons using the unicode provided, most of them are blank. The faicon folder is showing a | character instead of the folder-o icon which is what the unicode is for. Is there a package I need to enable these icons?

(require 'dash)
(require 's)
(require 'cl)
(require 'magit)

(setq default-process-coding-system '(utf-8-unix . utf-8-unix))

(defmacro with-face (STR &rest PROPS)
  "Return STR propertized with PROPS."
  `(propertize ,STR 'face (list ,@PROPS)))

(defmacro esh-section (NAME ICON FORM &rest PROPS)
  "Build eshell section NAME with ICON prepended to evaled FORM with PROPS."
  `(setq ,NAME
         (lambda () (when ,FORM
                 (-> ,ICON
                    (concat esh-section-delim ,FORM)
                    (with-face ,@PROPS))))))

(defun esh-acc (acc x)
  "Accumulator for evaluating and concatenating esh-sections."
  (--if-let (funcall x)
      (if (s-blank? acc)
        (concat acc esh-sep it))

(defun esh-prompt-func ()
  "Build `eshell-prompt-function'"
  (concat esh-header
          (-reduce-from 'esh-acc "" eshell-funcs)

(esh-section esh-dir
             "\xf07c"  ;  (faicon folder)
             (abbreviate-file-name (eshell/pwd))
             '(:foreground "gold" :bold ultra-bold :underline t))

(esh-section esh-git
             "\xe907"  ;  (git icon)
             '(:foreground "pink"))

(esh-section esh-clock
             "\xf017"  ;  (clock icon)
             (format-time-string "%H:%M" (current-time))
             '(:foreground "forest green"))

;; Below I implement a "prompt number" section
(setq esh-prompt-num 0)

(add-hook 'eshell-exit-hook (lambda () (setq esh-prompt-num 0)))

(advice-add 'eshell-send-input :before
            (lambda (&rest args) (setq esh-prompt-num (incf esh-prompt-num))))

(esh-section esh-num
             "\xf0c9"  ;  (list icon)
             (number-to-string esh-prompt-num)
             '(:foreground "brown"))

;; Separator between esh-sections
(setq esh-sep "  ")  ; or " | "

;; Separator between an esh-section icon and form
(setq esh-section-delim " ")

;; Eshell prompt header
(setq esh-header "\n ")  ; or "\n┌─"

;; Eshell prompt regexp and string. Unless you are varying the prompt by eg.
;; your login, these can be the same.
(setq eshell-prompt-regexp " ")   ; or "└─> "
(setq eshell-prompt-string " ")   ; or "└─> "

;; Choose which eshell-funcs to enable
(setq eshell-funcs (list esh-dir esh-git esh-clock esh-num))

;; Enable the new eshell prompt
(setq eshell-prompt-function 'esh-prompt-func)

1 Answer 1


I found out there was an issue with my fonts as I could not reference the icons using the unicode directly until after I installed the all-the-icons package. I then ran M-x all-the-icons-install-fonts Per the documentation, I added that package and edited my file to include the following

(require 'all-the-icons)
;; Use 'prepend for the NS and Mac ports or Emacs will crash.
(set-fontset-font t 'unicode (font-spec :family "FontAwesome") nil 'prepend)
(set-fontset-font t 'unicode (font-spec :family "all-the-icons") nil 'prepend)
;;Usage of icons should be like so
(esh-section esh-dir
             (all-the-icons-faicon "folder-open")  ;  (faicon folder)
             (abbreviate-file-name (eshell/pwd))
             '(:foreground "gold"))

(esh-section esh-git
             (all-the-icons-alltheicon "git")  ;  (git icon)
             '(:foreground "pink"))

;; After installing and requiring the packages, I was able to use the ;;unicode for the icons as expected, although some were no longer available ;;in the version used in all-the-icons Font Awesome ver 4.

(esh-section esh-clock
             "\xf017"  ;  (clock icon)
             (format-time-string "%H:%M" (current-time))
             '(:foreground "forest green"))

(esh-section esh-num
             "\xf0c9"  ;  (list icon)
             (number-to-string esh-prompt-num)
             '(:foreground "brown"))

After making the changes to my file I load this file in my eshell profile file. My prompt now looks as I expected

enter image description here

My gist is here if you would like to check it out. I am running macOS Big Sur

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.