TEMP COMMIT
This commit is contained in:
parent
6eb4964b98
commit
d80493cd63
@ -7,6 +7,61 @@
|
|||||||
(require 'eshell)
|
(require 'eshell)
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
|
|
||||||
|
(defun eshell-starship--file-names-present-p (&rest names)
|
||||||
|
"Test if any of NAMES (wildcards supported) exist in default directory."
|
||||||
|
(catch 'found
|
||||||
|
(dolist (name names)
|
||||||
|
(when (seq-filter #'(lambda (name)
|
||||||
|
(not (string-prefix-p "." name)))
|
||||||
|
(file-expand-wildcards name))
|
||||||
|
(throw 'found t)))))
|
||||||
|
|
||||||
|
(cl-defmacro eshell-starship-defmodule (name &body body
|
||||||
|
&key files
|
||||||
|
icon color allow-remote)
|
||||||
|
"Define a starship module called NAME.
|
||||||
|
FILES s used to detect weather to call the module. It is a list of wildcard
|
||||||
|
expressions. SYMBOL and COLOR control the output of the module. BODY should
|
||||||
|
return the string for the module, or nil if it could not be found."
|
||||||
|
(declare (indent defun))
|
||||||
|
`(defun ,(intern (format "eshell-starship--module-%s-func"
|
||||||
|
name)) ()
|
||||||
|
,(format "Module function for eshell-starship module %s." name)
|
||||||
|
(or (when (and ,(if allow-remote t
|
||||||
|
'(not (file-remote-p default-directory)))
|
||||||
|
(eshell-starship--file-names-present-p ,files))
|
||||||
|
(if-let (res (progn ,body))
|
||||||
|
(concat " via " (propertize (concat ,icon " " res)
|
||||||
|
'face (:foreground
|
||||||
|
,color)))))
|
||||||
|
"")))
|
||||||
|
|
||||||
|
(eshell-starship-defmodule cc
|
||||||
|
:files '("*.c" "*.h")
|
||||||
|
:icon "C"
|
||||||
|
:color "green yellow")
|
||||||
|
|
||||||
|
(defun eshell-starship--cc-status ()
|
||||||
|
"Return the current CC version if C files exist in `default-directory'.
|
||||||
|
Returns an empty string if no C .c or .h files exist or if current dir is
|
||||||
|
remote."
|
||||||
|
(or (unless (file-remote-p default-directory)
|
||||||
|
(when (eshell-starship--file-names-exist-p "*.h" "*.c")
|
||||||
|
(with-temp-buffer
|
||||||
|
(when (zerop (process-file "cc" nil t nil "-v"))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(when (re-search-forward
|
||||||
|
"^\\([-a-zA-Z]+\\) version \\([0-9]+\\.[0-9]+\\.[0-9]+\\)"
|
||||||
|
nil t)
|
||||||
|
(concat " via "
|
||||||
|
(propertize (concat "C v"
|
||||||
|
(match-string 2)
|
||||||
|
"-"
|
||||||
|
(match-string 1))
|
||||||
|
'face
|
||||||
|
'(:foreground "green yellow")))
|
||||||
|
))))) ""))
|
||||||
|
|
||||||
(defun eshell-starship--replace-home-with-tilda (path)
|
(defun eshell-starship--replace-home-with-tilda (path)
|
||||||
"If PATH beings with $HOME (the environment variable), replace it with ~."
|
"If PATH beings with $HOME (the environment variable), replace it with ~."
|
||||||
(let ((home (getenv "HOME")))
|
(let ((home (getenv "HOME")))
|
||||||
@ -226,6 +281,7 @@ END-TIME is the time when the command finished executing."
|
|||||||
(unless (file-writable-p dir)
|
(unless (file-writable-p dir)
|
||||||
" ")
|
" ")
|
||||||
(eshell-starship--vc-status)
|
(eshell-starship--vc-status)
|
||||||
|
(eshell-starship--cc-status)
|
||||||
(eshell-starship--last-command-time end-time)
|
(eshell-starship--last-command-time end-time)
|
||||||
(propertize "\n" 'read-only t 'rear-nonsticky t)
|
(propertize "\n" 'read-only t 'rear-nonsticky t)
|
||||||
(propertize
|
(propertize
|
||||||
|
1
init.el
1
init.el
@ -344,6 +344,7 @@ visual states."
|
|||||||
("C-x c b" . consult-bookmark)
|
("C-x c b" . consult-bookmark)
|
||||||
("C-x c d" . consult-fd)
|
("C-x c d" . consult-fd)
|
||||||
("C-x c g" . consult-ripgrep)
|
("C-x c g" . consult-ripgrep)
|
||||||
|
("C-x c y" . consult-yank-from-kill-ring)
|
||||||
("M-g i" . consult-imenu)
|
("M-g i" . consult-imenu)
|
||||||
("M-g I" . consult-imenu-multi)
|
("M-g I" . consult-imenu-multi)
|
||||||
("M-g r" . consult-imenu-multi)
|
("M-g r" . consult-imenu-multi)
|
||||||
|
Loading…
Reference in New Issue
Block a user