1234567891011121314151617181920212223242526272829303132333435363738 |
- ;; PROMPT_COMMAND='export PS1="$(pest)"'
- (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)
- (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)))
- (format T "~A: File not found" config-path))))
-
- (defvar *config* (config-parse "/home/swatson/Repos/cl-pest/config.toml"))
- ;; Colors
- (defvar *fg* (progn
- (if *config*
- (destructuring-bind (r g b) (subseq (assoc "fg" (cdr (assoc "colors" *config* :test #'equal)) :test #'equal) (- 4 3))
- (chlorophyll:create-rgb-color r g b))
- (chlorophyll:create-rgb-color 255 255 255))))
- (defvar *bg* (chlorophyll:create-rgb-color 0 0 0))
- (defvar *style* (chlorophyll:new-style
- :bold NIL
- :foreground *fg*
- :background *bg*))
- ;; Regex Scanners
- ;; TODO $HOME rendered as /home/user as opposed to ~
- (defvar *home-scan* (ppcre:create-scanner (concatenate 'string "^" (format NIL "~a" (user-homedir-pathname)))))
- (defun pwd ()
- (ppcre:regex-replace *home-scan* (uiop:getenv "PWD") "~/"))
- (defun main ()
- (setf *config* (config-parse "/home/swatson/Repos/cl-pest/config.toml"))
- (format T "~a λ " (chlorophyll:stylize *style* (pwd))))
|