add git branch and status to example laptop shell prompt

Signed-off-by: Ava Hahn <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2023-04-19 22:28:01 -07:00
parent 61076597d2
commit eb7bf830aa
Signed by: affine
GPG key ID: 3A4645B8CF806069

View file

@ -72,11 +72,32 @@
(inc i)) (inc i))
(concat "..." final))))) (concat "..." final)))))
(def in-a-git-repo?
'returns true or false depending on if currently in a git repo'
() (eq? (load-to-string git rev-parse --is-inside-work-tree) "true"))
(def git-repo-is-dirty?
'returns true or false depending on if current dir is a dirty git repo'
() (not (eq? (load-to-string git diff '--stat') "")))
(def git-status 'returns "(git:<branch>(!))" if dir is in a git repository'
()
(if (in-a-git-repo?)
(concat
"(git:"
(load-to-string git rev-parse --abbrev-ref HEAD)
(if (git-repo-is-dirty?)
"!"
"")
")")
''))
(def CFG_RELISH_L_PROMPT 'display user and dir (git info in future)' (def CFG_RELISH_L_PROMPT 'display user and dir (git info in future)'
() ()
(concat (concat
"[" USER "] " "[" USER "]" "\t"
(_fancy-cwd) " " (_fancy-cwd) "\t"
(git-status) "\t"
;; add more prompt elements here ;; add more prompt elements here
"\n" ;; newline before delimiter "\n" ;; newline before delimiter
)) ))