bug-bash
[Top][All Lists]
Advanced

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

Re: how to workaroun 'nl' being added to input-line after 49 characters.


From: Bob Proulx
Subject: Re: how to workaroun 'nl' being added to input-line after 49 characters....
Date: Sun, 13 Feb 2011 20:17:05 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

Linda Walsh wrote:
> But anyway, something else is is awry.
> 
> Now my root prompt, instead of being red, looks like:
> 
> "\[\033[1m\]\[\033[31m\]Ishtar:root#\[\033[0m\] "
> 
> ;-/

That will be due to incorrect quoting.  Which suggestion did you
implement?  There were several.

> What version of bash has the \[ \] characters to keep it from
> counting chars?

All of them.

Try this *exactly* as I post it.  I did test this.  It probably isn't
optimal.  But it does what you are asking.  And it is only a slight
variation from what you are currently using.

   _CRed=$(tput setaf 1)  #Red
   _CRST=$(tput sgr0)   #Reset
   _CBLD=$(tput bold)   #Bold
   _prompt_open=""
   _prompt_close=""
   _prompt=">"
   [[ $UID -eq 0 ]] && {
       _prompt_open="$_CBLD$_CRed"
       _prompt_close="$_CRST"
       _prompt="#"
   }
   PS1='\[$_prompt_open\]$(pwd "$PWD")$_prompt\[$_prompt_close\] ';

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]