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: Dennis Williamson
Subject: Re: how to workaroun 'nl' being added to input-line after 49 characters....
Date: Sun, 13 Feb 2011 16:40:31 -0600

On Sun, Feb 13, 2011 at 3:50 PM, Linda Walsh <address@hidden> wrote:
> I'm having a problem, I think,  due to my setting the prompt in
> 'root' mode, to a different color.  This results in me being able to
> enter only 49 characters on the input line before it wraps to the next
> line.
>
> I add an open and close sequence to the normal prompt (which has no
> weird problems with changing the input line length):
>
>
>   #specific to linux console compat emulations
>   _CRed="$(echo -en "\033[31m")"  #Red
>   _CRST="$(echo -en "\033[0m")"   #Reset
>   _CBLD="$(echo -en "\033[1m")"   #Bold
>   export _prompt_open=""
>   export _prompt_close=">"
>   [[ $UID -eq 0 ]] && {
>       _prompt_open="$_CBLD$_CRed"
>       _prompt_close="#$_CRST"
>   }
>   export PS1='${_prompt_open}$(spwd "$PWD")${_prompt_close} ';
>
> Is there some easy way to tell bash either to not keep track of what it
> thinks is the screen width (and just allow it to wrap, if that's possible),
> or to reset bash's idea of where it thinks it is on the line?
>
> Thanks!
> Linda
>
>
>
>

Here's another way to do it:

#specific to linux console compat emulations
_CRed='\[\033[31m\]'  #Red
_CRST='\[\033[0m\]'  #Reset
_CBLD='\[\033[1m\]'  #Bold
export _prompt_open=""
export _prompt_close=">"
[[ $UID -eq 0 ]] && {
    _prompt_open="$_CBLD$_CRed"
    _prompt_close="#$_CRST"
}
export PS1="${_prompt_open}$(spwd "$PWD")${_prompt_close} "

Note the simplification of the variable assignments and the change in
quotes in the final command. Also, it's probably not necessary to do
any of those exports.



reply via email to

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