gash: Use a simple prompt on Mes.

* gash/gash.scm [mes] (prompt): Use plain ol' "$".
This commit is contained in:
Timothy Sample 2023-02-08 13:10:57 -06:00
parent b741e2a3e7
commit a1794de9f6
1 changed files with 19 additions and 15 deletions

View File

@ -142,21 +142,25 @@ There is NO WARRANTY, to the extent permitted by law.
(else (exit (run-repl (current-input-port) parse?)))))))) (else (exit (run-repl (current-input-port) parse?))))))))
(thunk))) (thunk)))
(define prompt (cond-expand
(let* ((l (string #\001)) (mes (define (prompt) "$ "))
(r (string #\002)) (else
(e (string #\033)) (define prompt
(user (getenv "USER")) (let* ((l (string #\001))
(host (gethostname)) (r (string #\002))
(home (getenv "HOME"))) (e (string #\033))
(lambda () (user (getenv "USER"))
(let* ((cwd (getcwd)) (host (gethostname))
(cwd (if (string-prefix? home cwd) (home (getenv "HOME")))
(string-replace cwd "~" 0 (string-length home)) (lambda ()
cwd))) (let* ((cwd (getcwd))
(string-append (cwd (if (string-prefix? home cwd)
l e "[01;32m" r user "@" host l e "[00m" r ":" (string-replace cwd "~" 0 (string-length home))
l e "[01;34m" r cwd l e "[00m" r (if (zero? (getuid)) "# " "$ ")))))) cwd)))
(string-append
l e "[01;32m" r user "@" host l e "[00m" r ":"
l e "[01;34m" r cwd l e "[00m" r
(if (zero? (getuid)) "# " "$ "))))))))
(define (string-prefix s1 s2) (define (string-prefix s1 s2)
(substring/read-only s1 0 (string-prefix-length s1 s2))) (substring/read-only s1 0 (string-prefix-length s1 s2)))