Some git prompt fixes
This commit is contained in:
parent
7a7f24844a
commit
3f5e53a83c
16
init.el
16
init.el
@ -854,6 +854,7 @@ Take directly from doom-modeline."
|
||||
|
||||
;; eat
|
||||
(use-package eat
|
||||
:bind ("C-c V" . my/project-eat-or-default)
|
||||
:config
|
||||
(defvar my/project-eat-hash-table (make-hash-table :test 'equal)
|
||||
"Hash table that maps project root dirs to eat buffers.")
|
||||
@ -869,7 +870,7 @@ Take directly from doom-modeline."
|
||||
(let ((eat-buffer-name (concat "*eat for project " default-directory "*")))
|
||||
(puthash default-directory
|
||||
(eat)
|
||||
my/project-eaeat-hash-table)))))
|
||||
my/project-eat-hash-table)))))
|
||||
(defun my/project-eat-or-default ()
|
||||
"Open an eat for the current project, otherwise, open a normal eat."
|
||||
(interactive)
|
||||
@ -925,6 +926,13 @@ If no name is given, list all bookmarks instead."
|
||||
(when my/eshell-bm-auto-ls
|
||||
(eshell/ls)))
|
||||
(eshell-print (string-join (bookmark-all-names) " "))))
|
||||
(defun my/-git-process-lines (&rest flags)
|
||||
"Run `vc-git-program' and return an array of its output lines."
|
||||
(with-temp-buffer
|
||||
(apply 'vc-git-command t 0 nil flags)
|
||||
(if (zerop (buffer-size))
|
||||
'()
|
||||
(string-lines (buffer-substring-no-properties 1 (buffer-size))))))
|
||||
(defun my/-replace-home-with-tilda (path)
|
||||
(let ((home (getenv "HOME")))
|
||||
(if (equal home path)
|
||||
@ -951,7 +959,7 @@ If no name is given, list all bookmarks instead."
|
||||
(my/-replace-home-with-tilda default-directory))))
|
||||
(defun my/-eshell-prompt-status-char-for-branch (branch remote)
|
||||
"Get the status char representing the relation between BRANCH and REMOTE."
|
||||
(let ((lines (process-lines vc-git-program
|
||||
(let ((lines (my/-git-process-lines
|
||||
"rev-list"
|
||||
"--left-right"
|
||||
(concat branch "..." remote)))
|
||||
@ -969,7 +977,7 @@ If no name is given, list all bookmarks instead."
|
||||
(to-local ?))))
|
||||
(defun my/-eshell-prompt-current-branch-status ()
|
||||
"Get the status char for the current branch and its remote."
|
||||
(let ((refs (process-lines vc-git-program
|
||||
(let ((refs (my/-git-process-lines
|
||||
"for-each-ref"
|
||||
"--format=%(HEAD)%00%(refname:short)%00%(upstream:short)"
|
||||
"refs/heads")))
|
||||
@ -982,7 +990,7 @@ If no name is given, list all bookmarks instead."
|
||||
(caddr split-ref))))))))
|
||||
(defun my/-eshell-prompt-git-state-chars ()
|
||||
"Get chars, like + and ✘ for `my/-eshell-prompt-function'."
|
||||
(let ((lines (process-lines vc-git-program "status" "--porcelain=v1"))
|
||||
(let ((lines (my/-git-process-lines "status" "--porcelain=v1"))
|
||||
(branch-status (my/-eshell-prompt-current-branch-status))
|
||||
(status-arr))
|
||||
(dolist (line lines)
|
||||
|
Loading…
Reference in New Issue
Block a user