Unix Technical Forum

No linebreak when coloring prompt

This is a discussion on No linebreak when coloring prompt within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> I have added the following line to /etc/profile: PS1="\e[0;32m$PS1\e[0;0m" Now I have a colored prompt. But if a command ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-19-2008, 10:34 AM
Sebastian Stein
 
Posts: n/a
Default No linebreak when coloring prompt

I have added the following line to /etc/profile:

PS1="\e[0;32m$PS1\e[0;0m"

Now I have a colored prompt. But if a command is longer then a line, there
is no linebreak. It just jumps back to the beginning (carriage return) of
the current line.

In wish manpage are the escape sequences described?

Sebastian
--
http://www.halle-ist-schoen.de/
Bilddokumentation der schoensten Saalestadt
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-19-2008, 10:34 AM
Sebastian Stein
 
Posts: n/a
Default Re: No linebreak when coloring prompt

On Tue, 13 Apr 2004 14:07:58 -0000, Sebastian Stein <seb_stein@gmx.de> wrote:
> I have added the following line to /etc/profile:
>
> PS1="\e[0;32m$PS1\e[0;0m"
>
> Now I have a colored prompt. But if a command is longer then a line, there
> is no linebreak. It just jumps back to the beginning (carriage return) of
> the current line.


I found the solution. The correct line must be:

PS1="\[\e[0;32m\]$PS1\[\e[0;0m\]"

Sebastian
--
http://www.hpfsc.de/ - die Seite rund um:
Assembler, Bundeswehr, TFT LCDs, Halle/Saale, Fahrradtouren, Neuseeland,
Wanderstaat Mauma, Raumschiff USS Nathan, Enemy Room, MLCAD Tutorial
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-19-2008, 10:34 AM
David
 
Posts: n/a
Default Re: No linebreak when coloring prompt

Sebastian Stein wrote:
> I have added the following line to /etc/profile:
>
> PS1="\e[0;32m$PS1\e[0;0m"
>
> Now I have a colored prompt. But if a command is longer then a line, there
> is no linebreak. It just jumps back to the beginning (carriage return) of
> the current line.
>
> In wish manpage are the escape sequences described?


I do it like this and still occasionally the line doesn't wrap
properly though not very often. This gives me a red prompt for
root and a yellow prompt for users and also shows the CWD.

elif [ "`id -un`" = "root" ]; then
PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] ';
else
PS1='\[\033[1;33m\]\h:\w\$\[\033[0m\] ';
fi

--
Confucius: He who play in root, eventually kill tree.
Registered with The Linux Counter. http://counter.li.org/
Slackware 9.1.0 Kernel 2.4.25 SMP i686 (GCC) 3.3.3
Uptime: 11 days, 23:53, 1 user, load average: 0.01, 0.09, 0.09
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:43 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com