[Techtalk] shell scripting - modifying your prompt

Andrea Landaker qirien at icecavern.net
Tue Feb 11 15:59:34 EST 2003


> The problem I got after adding the escape characters is that bash seemed to
> interpret them litterally, meaning a color switch (like: "\e[35m") was
> treated as if the prompt got 6 characters longer. This lead to a CR
> (carriage return) after bash decided the maximum screen width was exceeded
> (prompt + command string) but without a LF (line feed)... the LF came
> numerically where it should...

Hmm, my husband helped set mine up, so I'm not really sure on the nitty-gritty 
details.  But using color switches like \[\e[32m\] (that's green) worked for 
me.

You can see my .prompt here - http://www.icecavern.net/~qirien/prompt - be 
warned, it's pretty messy.  The color constants I defined might be useful to 
you, though.  It also uses a little Ruby script called cutpwd that you can 
find here - http://www.icecavern.net/~qirien/cutpwd - basically, if you're in 
a directory structure longer than length x, it trims it to be length x with a 
little "..." on the beginning.  Very useful, IMHO, especially when navigating 
Java code trees.

-- 
Andrea Landaker
qirien at icecavern.net
http://www.icecavern.net/~qirien/



More information about the Techtalk mailing list