diff --git a/elisp/eshell-starship.el b/elisp/eshell-starship.el index f57af58..5539c53 100644 --- a/elisp/eshell-starship.el +++ b/elisp/eshell-starship.el @@ -99,6 +99,9 @@ FIELD should be one of the keys in `eshell-starship--modules-by'." "A list of (NAME IS-DIR MODULE). These represent files that cannot be stored in `eshell-starship--module-by'.") +(defvar-local eshell-starship--is-first-prompt t + "Non-nil if we have never printed a prompt in this buffer.") + ;;; Module API (defvar eshell-starship-modules (make-hash-table :test 'equal) @@ -988,8 +991,11 @@ Return a hash table mapping module names to their output." (defun eshell-starship--render-prompt () "Actually produce the prompt." (concat - (unless (<= (line-number-at-pos) 3) - "\n") + (prog1 + (unless (or eshell-starship--is-first-prompt + (zerop (buffer-size))) + "\n") + (setq eshell-starship--is-first-prompt nil)) (let ((mods (eshell-starship--build-module-string))) (add-face-text-property 0 (length mods) 'default t mods) mods)))