Help on controlling BASH command line
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Mon Jun 6 19:38:14 UTC 2005
On Mon, Jun 06, 2005 at 03:27:12PM -0400, John Wildberger wrote:
> On Monday 06 June 2005 01:44 pm, Lennart Sorensen wrote:
>
> > The new line is a feature of bash that it knows about, so it starts
> > counting fresh. If it works without that newline in the prompt, then I
> > will be impressed, since I don't think bash knows about escape codes
> > (being escape stuff, not just bash \ codes). Your test doesn't seem to
> > show anything. Of course setting PS1= works since bash sees plain ascii
> > charaters being typed as a command and of course that wraps fine. It is
> > when it tries to display the prompt and figure out how long it is that
> > things break, which your newline at the end of the prompt conviniently
> > avoids by starting a new prompt line with no escape codes to confuse
> > bash.
> >
> > I personally can't imagine wanting to have a two line prompt. Seems
> > inefficient.
>
>
> 1 [john]: 02:57 PM [~] $ PS1="\u [\w]\$ "
> 2 john [~]$
> 3 john [~]$ PS1="\n\e[43;1m[\u]:\e[m \e[42;1m \@ \e[m \e[44;1m [\w]
> 4 \e[m\n\\$"
> 5
> 6 [john]: 02:59 PM [~]
> 7 $PS1="\e[43;1m[\u]:\e[m \e[42;1m \@ \e[m \e[44;1m [\w] \e[m\\$"
> 8 [john]: 03:00 PM [~] $
> 9 [john]: 03:00 PM [~] $ PS1="\e[43;1m[\u]:\e[m \e[42;1m \@ \e[m \e[44;1m
> 10 [\w] \e[m\n\\$"
> 11 [john]: 03:08 PM [~]
> 12 $
>
> Line 1: PS1 changed to simple prompt
> Line 3: Changed to complex prompt with \n at both ends
> Line 7: similar to line 3,but without the two newlines.
> Line 8: new prompt.
> Line 9: similar to line 3, but with \n at the end only
> Line 12 Entry point for new commands.
>
> As an aside, I usually add my newly modified prompt to /etc/bashrc. This way
> the modification will be seen by all users and by root. I also don't bother
> of showing the \h option, which would just show 'localhost' in my usage. It
> might be useful for more sophisticated users though!
>
> Why you want to use prompt extending over several lines:
> When compiling from source there is a stage when you have to
> execute ./configure. This might require sometimes a long string of options
> that can easily extend over several lines. Examples can be found in LFS
> (Linux From Scratch). With my modified prompt I had never any problems, even
> with as many as 4 lines of commands and options strung together.
Which version of bash are you using?
It does not do proper wrapping here using bash 2.05.0(1)-release using
your prompt above.
When I switch to bash3 then it does work. bash2 is often the default
due to bugs/incompatible changes in bash3.
You may be using bash 3.x which likely fixed that problem in a similar
way to how zsh has fixed it years ago.
Lennart Sorensen
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list