Compare commits

..

No commits in common. "7310a981e789cdb9f3951b78a843e0504593c2d3" and "47039d4bfedfa7497f9caaa4b6df26f0667e8ad2" have entirely different histories.

2 changed files with 31 additions and 68 deletions

View File

@ -62,83 +62,49 @@ STATUS-LINE is the first line of output from \"git status --porcelain=v1 -b\"."
(defun eshell-starship--prompt-git-has-stash () (defun eshell-starship--prompt-git-has-stash ()
"Return t if the current git directory has a stash, nil otherwise." "Return t if the current git directory has a stash, nil otherwise."
(zerop (process-file vc-git-program nil nil nil (= (process-file vc-git-program nil nil nil
"rev-parse" "--verify" "refs/stash"))) "rev-parse" "--verify" "refs/stash") 0))
(defun eshell-starship--prompt-git-state-chars () (defun eshell-starship--prompt-git-state-chars ()
"Get chars, like + and ✘ for `eshell-starship--prompt-function'." "Get chars, like + and ✘ for `eshell-starship--prompt-function'."
(with-temp-buffer (let* ((lines (eshell-starship--git-process-lines "status" "--porcelain=v1" "-b"))
(when (zerop (vc-git-command t nil nil "status" "--porcelain=v1" "-b")) (branch-status (eshell-starship--prompt-current-branch-status
(goto-char (point-min)) (car lines)))
(cl-loop with command-error-function = nil (status-arr))
with status-arr = nil (dolist (line (cdr lines))
with first-line = (buffer-substring-no-properties (cl-loop with fields = (string-split line " " t " *")
(point) (pos-eol)) with status-str = (car-safe fields)
;; account for newline at end for status-char across status-str
with line-count = (car (buffer-line-statistics))
with cur-buf = (current-buffer)
do (forward-line)
for x_status = (char-after)
for y_status = (char-after (1+ (point)))
until (> (line-number-at-pos) line-count)
do do
(cond (cond ((or (= status-char ?M) (= status-char ?T))
((or (= ?D x_status y_status) (push ?! status-arr))
(= ?A x_status y_status) ((= status-char ??)
(= ?U x_status y_status) (push ?? status-arr))
(and (= ?A x_status) (= ?U y_status)) ((or (= status-char ?A) (= status-char ?C))
(and (= ?U x_status) (= ?D y_status)) (push ?+ status-arr))
(and (= ?U x_status) (= ?A y_status)) ((= status-char ?D)
(and (= ?D x_status) (= ?U y_status))) (push ? status-arr))
(push ?= status-arr)) ((= status-char ?R)
((or (= x_status ?D) (= y_status ?D)) (push status-arr))
(push ? status-arr)) ((= status-char ?U)
((or (= x_status ?R) (= y_status ?R)) (push ?= status-arr)))))
(push status-arr)) (when (eshell-starship--prompt-git-has-stash)
((= y_status ?M) (push ?$ status-arr))
(push ?! status-arr)) (sort status-arr #'<)
((or (= x_status ?A) (= x_status ?M)) (when branch-status
(push ?+ status-arr)) (push branch-status status-arr))
((= x_status y_status ??) (apply 'string (seq-uniq status-arr))))
(push ?? status-arr)))
finally
(sort status-arr #'(lambda (a b)
(cond
((= a ?=)
t)
((= b ?=)
nil)
(t
(< a b)))))
(when (eshell-starship--prompt-git-has-stash)
(if (= (car status-arr) ?=)
(setq status-arr (append '(?= ?$) (cdr status-arr)))
(push ?$ status-arr)))
(when-let (branch-status (eshell-starship--prompt-current-branch-status
first-line))
(push branch-status status-arr))
finally return (apply 'string (seq-uniq status-arr))))))
(defun eshell-starship--prompt-git-get-operation () (defun eshell-starship--prompt-git-get-operation ()
"Return the current git operation. For example, a revert." "Return the current git operation. For example, a revert."
(let ((git-dir (expand-file-name ".git" (vc-git-root default-directory)))) (let ((git-dir (expand-file-name ".git" (vc-git-root default-directory))))
(cond (cond
((file-exists-p (expand-file-name "rebase-apply/applying" git-dir)) ((file-exists-p (expand-file-name "REVERT_HEAD" git-dir))
"AM") "REVERTING")
((file-exists-p (expand-file-name "rebase-apply/rebasing" git-dir))
"REBASE")
((file-exists-p (expand-file-name "rebase-apply" git-dir))
"AM/REBASE")
((file-exists-p (expand-file-name "rebase-merge" git-dir)) ((file-exists-p (expand-file-name "rebase-merge" git-dir))
"REBASING") "REBASING")
((file-exists-p (expand-file-name "CHERRY_PICK_HEAD" git-dir))
"CHERRY-PICKING")
((file-exists-p (expand-file-name "MERGE_HEAD" git-dir)) ((file-exists-p (expand-file-name "MERGE_HEAD" git-dir))
"MERGING") "MERGING"))))
((file-exists-p (expand-file-name "BISECT_LOG" git-dir))
"BISECTING")
((file-exists-p (expand-file-name "REVERT_HEAD" git-dir))
"REVERTING"))))
(defun eshell-starship--prompt-git-status () (defun eshell-starship--prompt-git-status ()
"Get git status for `eshell-starship--prompt-function'." "Get git status for `eshell-starship--prompt-function'."

View File

@ -110,9 +110,6 @@
;; Set fonts ;; Set fonts
(add-to-list 'default-frame-alist '(font . "FiraCode Nerd Font Mono-12")) (add-to-list 'default-frame-alist '(font . "FiraCode Nerd Font Mono-12"))
;; For source lookups
(setq find-function-C-source-directory "~/src/emacs/src/")
;; Some settings for programming ;; Some settings for programming
(setq-default indent-tabs-mode nil (setq-default indent-tabs-mode nil
tab-width 4 tab-width 4