From eb7bf830aa256f50516daaa9f8efa2742bde397c Mon Sep 17 00:00:00 2001 From: Ava Hahn Date: Wed, 19 Apr 2023 22:28:01 -0700 Subject: [PATCH] add git branch and status to example laptop shell prompt Signed-off-by: Ava Hahn --- snippets/avas-laptop-prompt.rls | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/snippets/avas-laptop-prompt.rls b/snippets/avas-laptop-prompt.rls index 048fca3..a937db7 100644 --- a/snippets/avas-laptop-prompt.rls +++ b/snippets/avas-laptop-prompt.rls @@ -72,11 +72,32 @@ (inc i)) (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:(!))" 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)' () (concat - "[" USER "] " - (_fancy-cwd) " " + "[" USER "]" "\t" + (_fancy-cwd) "\t" + (git-status) "\t" ;; add more prompt elements here "\n" ;; newline before delimiter ))