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
|
;; eat
|
||||||
(use-package eat
|
(use-package eat
|
||||||
|
:bind ("C-c V" . my/project-eat-or-default)
|
||||||
:config
|
:config
|
||||||
(defvar my/project-eat-hash-table (make-hash-table :test 'equal)
|
(defvar my/project-eat-hash-table (make-hash-table :test 'equal)
|
||||||
"Hash table that maps project root dirs to eat buffers.")
|
"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 "*")))
|
(let ((eat-buffer-name (concat "*eat for project " default-directory "*")))
|
||||||
(puthash default-directory
|
(puthash default-directory
|
||||||
(eat)
|
(eat)
|
||||||
my/project-eaeat-hash-table)))))
|
my/project-eat-hash-table)))))
|
||||||
(defun my/project-eat-or-default ()
|
(defun my/project-eat-or-default ()
|
||||||
"Open an eat for the current project, otherwise, open a normal eat."
|
"Open an eat for the current project, otherwise, open a normal eat."
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -925,6 +926,13 @@ If no name is given, list all bookmarks instead."
|
|||||||
(when my/eshell-bm-auto-ls
|
(when my/eshell-bm-auto-ls
|
||||||
(eshell/ls)))
|
(eshell/ls)))
|
||||||
(eshell-print (string-join (bookmark-all-names) " "))))
|
(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)
|
(defun my/-replace-home-with-tilda (path)
|
||||||
(let ((home (getenv "HOME")))
|
(let ((home (getenv "HOME")))
|
||||||
(if (equal home path)
|
(if (equal home path)
|
||||||
@ -951,7 +959,7 @@ If no name is given, list all bookmarks instead."
|
|||||||
(my/-replace-home-with-tilda default-directory))))
|
(my/-replace-home-with-tilda default-directory))))
|
||||||
(defun my/-eshell-prompt-status-char-for-branch (branch remote)
|
(defun my/-eshell-prompt-status-char-for-branch (branch remote)
|
||||||
"Get the status char representing the relation between BRANCH and 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"
|
"rev-list"
|
||||||
"--left-right"
|
"--left-right"
|
||||||
(concat branch "..." remote)))
|
(concat branch "..." remote)))
|
||||||
@ -969,7 +977,7 @@ If no name is given, list all bookmarks instead."
|
|||||||
(to-local ?))))
|
(to-local ?))))
|
||||||
(defun my/-eshell-prompt-current-branch-status ()
|
(defun my/-eshell-prompt-current-branch-status ()
|
||||||
"Get the status char for the current branch and its remote."
|
"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"
|
"for-each-ref"
|
||||||
"--format=%(HEAD)%00%(refname:short)%00%(upstream:short)"
|
"--format=%(HEAD)%00%(refname:short)%00%(upstream:short)"
|
||||||
"refs/heads")))
|
"refs/heads")))
|
||||||
@ -982,7 +990,7 @@ If no name is given, list all bookmarks instead."
|
|||||||
(caddr split-ref))))))))
|
(caddr split-ref))))))))
|
||||||
(defun my/-eshell-prompt-git-state-chars ()
|
(defun my/-eshell-prompt-git-state-chars ()
|
||||||
"Get chars, like + and ✘ for `my/-eshell-prompt-function'."
|
"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))
|
(branch-status (my/-eshell-prompt-current-branch-status))
|
||||||
(status-arr))
|
(status-arr))
|
||||||
(dolist (line lines)
|
(dolist (line lines)
|
||||||
|
Loading…
Reference in New Issue
Block a user