Compare commits
2 Commits
5479efabee
...
df92555538
| Author | SHA1 | Date | |
|---|---|---|---|
| df92555538 | |||
| 4e25b535ca |
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'dash)
|
||||||
(require 'subr-x)
|
(require 'subr-x)
|
||||||
(require 'seq)
|
(require 'seq)
|
||||||
(require 'eshell)
|
(require 'eshell)
|
||||||
@ -57,10 +58,13 @@
|
|||||||
;; Inspired by https://github.com/howardabrams/dot-files/blob/master/emacs-eshell.org#special-prompt
|
;; Inspired by https://github.com/howardabrams/dot-files/blob/master/emacs-eshell.org#special-prompt
|
||||||
"Return name of git branch of current directory, as a string.
|
"Return name of git branch of current directory, as a string.
|
||||||
|
|
||||||
The format will be BASE-DIR::BRANCH-NAME, where BASE-DIR is the
|
The format will be BASE-NAME@BASE-DIR[STATE], where BASE-DIR is
|
||||||
directory containing the .git directory or link file of the
|
the directory containing the .git directory or link file of the
|
||||||
current git repository, and BRANCH-NAME is the name of the
|
current git repository, and BRANCH-NAME is the name of the
|
||||||
current branch.
|
current branch. STATE will display information about whether the
|
||||||
|
worktree is dirty or whether the repository needs pushing. When
|
||||||
|
no extra state information is available, STATE will be empty and
|
||||||
|
the brackets will be ommitted.
|
||||||
|
|
||||||
Return the empty string if the current directory is not part of a
|
Return the empty string if the current directory is not part of a
|
||||||
git repository."
|
git repository."
|
||||||
@ -73,8 +77,22 @@ git repository."
|
|||||||
(save-match-data
|
(save-match-data
|
||||||
(let* ((git-branch (string-trim
|
(let* ((git-branch (string-trim
|
||||||
(shell-command-to-string "git rev-parse --abbrev-ref HEAD")))
|
(shell-command-to-string "git rev-parse --abbrev-ref HEAD")))
|
||||||
(base-dir (file-name-base (string-trim-right repo-dir "/?"))))
|
(base-dir (file-name-base (string-trim-right repo-dir "/?")))
|
||||||
(format "%s@%s" git-branch base-dir))))))
|
(state-list (cl-remove-if #'null
|
||||||
|
(list
|
||||||
|
(when (file-exists-p (file-name-concat "." ".git" "MERGE_HEAD"))
|
||||||
|
"merge")
|
||||||
|
(unless (= 0 (call-process "git" nil nil nil
|
||||||
|
"diff" "--no-ext-diff" "--quiet"))
|
||||||
|
"dirty")
|
||||||
|
(unless (= 0 (call-process "git" nil nil nil
|
||||||
|
"diff" "--no-ext-diff" "--quiet" "--cached"))
|
||||||
|
"uncommitted")
|
||||||
|
(unless (string-empty-p (shell-command-to-string "git stash list --quiet"))
|
||||||
|
"stash")))))
|
||||||
|
(if state-list
|
||||||
|
(format "%s@%s[%s]" git-branch base-dir (apply #'concat (-interpose "|" state-list)))
|
||||||
|
(format "%s@%s" git-branch base-dir)))))))
|
||||||
|
|
||||||
(defun eshell/default-prompt-function ()
|
(defun eshell/default-prompt-function ()
|
||||||
"A prompt for eshell of the form
|
"A prompt for eshell of the form
|
||||||
|
|||||||
@ -770,12 +770,20 @@ If there's no such open checkbox, emit a message and stay put."
|
|||||||
(unless (derived-mode-p 'org-mode)
|
(unless (derived-mode-p 'org-mode)
|
||||||
(user-error "Not in Org buffer, exiting"))
|
(user-error "Not in Org buffer, exiting"))
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(let ((original-point (point)))
|
||||||
(org-back-to-heading 'invisible-ok)
|
(widen)
|
||||||
(org-narrow-to-subtree)
|
(org-back-to-heading 'invisible-ok)
|
||||||
(unless (or (re-search-forward "\\[-\\]" nil 'no-error)
|
(org-narrow-to-subtree)
|
||||||
(re-search-forward "\\[ \\]" nil 'no-error))
|
(unless
|
||||||
(message "No open checkbox in subtree"))))
|
;; Yes, progn is not strictly necessary, but it feels cleaner this way.
|
||||||
|
(or (progn
|
||||||
|
(goto-char (point-min))
|
||||||
|
(re-search-forward " \\[-\\] " nil 'no-error))
|
||||||
|
(progn
|
||||||
|
(goto-char (point-min))
|
||||||
|
(re-search-forward " \\[ \\] " nil 'no-error)))
|
||||||
|
(message "No open checkbox in subtree")
|
||||||
|
(goto-char original-point)))))
|
||||||
|
|
||||||
|
|
||||||
;;; Calendar
|
;;; Calendar
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user