color prompt



On 2012-10-31, Ranousse <ranousse at gmx.com> wrote:

> It doesn't surprise me, since I think there's something missing in the
> solution. When colorizing prompts (bash, lftp or octave for instance) I
> usually use a string like this one
> start: "\[\e[35m\]"
> end: "\[\e[m\]"
> In the previous example the \[ and \] around text are missing.

Well, you can edit the strings in colorterm.lisp, which I did, as shown
by the patch below. But when I run the modified colorterm function, I
just get extra square brackets in the output. I tried it with terminal
0.2.8 and xterm 229 (on an xubuntu system). I also tried it with zero or
two backslashes before each square bracket -- same result.

best

Robert Dodier

PS.
diff --git a/share/contrib/colorterm.lisp b/share/contrib/colorterm.lisp
index 59ec4ec..01dfce8 100644
--- a/share/contrib/colorterm.lisp
+++ b/share/contrib/colorterm.lisp
@@ -46,13 +46,13 @@
 (defun $colorterm ()
     (let ((escape-char (code-char 27)))
         (setf *prompt-prefix* 
-            (format nil "~a[00;~am" escape-char *prompt-color*))
+            (format nil "\[~a[00;~am\]" escape-char *prompt-color*))
         (setf *prompt-suffix* 
-            (format nil "~a[00;~am" escape-char *input-color*))
+            (format nil "\[~a[00;~am\]" escape-char *input-color*))
         (setf *general-display-prefix* 
-            (format nil "~a[00;~am" escape-char *output-color*))
+            (format nil "\[~a[00;~am\]" escape-char *output-color*))
         (setf *maxima-epilog* 
-            (format nil "~a[00m" escape-char))))
+            (format nil "\[~a[00m\]" escape-char))))