4baca4bc57fa677a239421d8fcce2058bcc0f4f7
commit 4baca4bc57fa677a239421d8fcce2058bcc0f4f7
Author: Simon Watson <spesk@pm.me>
Date: Mon Aug 14 15:23:32 2023 -0400

Added handling for no config file

diff --git a/config.toml b/config.toml
index db07cb0..7f969c5 100644
--- a/config.toml
+++ b/config.toml
@@ -1,7 +1,3 @@
-[colors]
-fg = [255, 255, 255]
-bg = [0, 0, 0]
-
[git]
display_head = true
display_branch = true
diff --git a/pest.lisp b/pest.lisp
index 5112132..9610c25 100644
--- a/pest.lisp
+++ b/pest.lisp
@@ -5,15 +5,45 @@
"Shortcut function over :test #'equal for working with TOML alists"
(cdr (assoc key alist :test #'equal)))

+(defun find-config ()
+ (let ((config-paths (list
+ (concatenate 'string (uiop:getenv "HOME") "/.config/pest/config.toml")
+ "/etc/pest/config.toml"
+ (concatenate 'string (uiop:getenv "PWD") "./config"))))
+ (loop for path-str in config-paths
+ do (if (probe-file path-str)
+ (return-from find-config path-str)))))
+
(defun config-parse (&optional path)
- (let ((config-path (if path path (concatenate 'string (uiop:getenv "HOME") "/.config/pest/config.toml"))))
- (if (probe-file config-path)
+ (let ((config-path (if path path (find-config))))
+ (if config-path
(with-open-file (fh config-path :direction :input)
(let ((file-content (with-output-to-string (out)
(loop for line = (read-line fh nil)
while line
do (format out "~a~%" line)))))
- (clop:parse file-content))))))
+ (clop:parse file-content)))
+ (clop:parse "
+[git]
+display_head = false
+display_branch = false
+git_prefix = \"\"
+[git.colors]
+fg = [0, 120, 50]
+bg = [0, 0, 0]
+
+[prompt]
+display_user = false
+user_suffix = \"\"
+display_hostname = false
+hostname_suffix = \"\"
+display_pwd = true
+pwd_suffix = \"\"
+prompt_char = \" λ \"
+[prompt.colors]
+fg = [255, 255, 255]
+bg = [0, 0, 0]
+"))))

(defvar *config* NIL)

@@ -100,7 +130,7 @@


(defun reload-config ()
- (setf *config* (config-parse "~/Repos/cl-pest/config.toml"))
+ (setf *config* (config-parse))
(setf *prompt-style* (make-style *config* "prompt"))
(if (check-git-enabled *config*)
(setf *git-style* (make-style *config* "git"))))