[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash prompt won't wrap properly



On Sun, Apr 15, 2007 at 09:15:52PM +0000, Tyler Smith wrote:
From: Tyler Smith <tyler.smith@mail.mcgill.ca>
To: debian-user@lists.debian.org
Subject: bash prompt won't wrap properly
X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-26) on murphy.debian.org
X-Spam-Level: X-Spam-Status: No, score=-1.3 required=4.0 tests=AWL,BAYES_20 autolearn=no version=3.1.4
Organization: Business Internet

Hi,

I've modified my bash prompt to display the number of minutes of
battery time left. I use the following code in my .bashrc:

##########

alias bt="acpi | awk '{print \$5}' | awk -F : '{print \$1*60 + \$2}'"

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm)
   PS1='\033[01;31m\]$(bt)\033[00m\]|\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]-> '
   ;;
*)
   PS1='\u:\W-> '
   ;;
esac

###########

This works as expected, except that now if I enter a line that is
longer than the screen width, instead of continuing on the *next* line
it continues on the *same* line, over-writing  what is there. I can
still pass the line to bash, which interprets it correctly, but it is
confusing and pretty much impossible to edit. What did I do wrong?

Tyle
I encountered the same problem and I solved it adding \]\n[\ in my PS1.

my PS1:

PS1="${magenta}[\[$TIME\] \[$LOAD\]]\[${NC}\]\n[\u@\h \[${BLUE}\]\#\[$NC\]]\w\$ "
hth.
--
Gérard



Reply to: