[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 14:59:52 -0700 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Linda Walsh 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.
It sounds like you have forgotten to enclose non-printing characters
in your prompt with \[...\].
> #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?
The bash manual says:
PROMPTING
\[ begin a sequence of non-printing characters, which could
be used to embed a terminal control sequence into the
prompt
\] end a sequence of non-printing characters
Therefore you want something like:
_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 1000 ]] && {
_prompt_open="$_CBLD$_CRed"
_prompt_close="#$_CRST"
}
export PS1='\[${_prompt_open}\]$(pwd "$PWD")\[${_prompt_close}\] ';
But I didn't test the above.
Bob
- how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters....,
Bob Proulx <=
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Dennis Williamson, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Andreas Schwab, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Bob Proulx, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Bob Proulx, 2011/02/13
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Greg Wooledge, 2011/02/14
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Bob Proulx, 2011/02/14
- Re: how to workaroun 'nl' being added to input-line after 49 characters...., Linda Walsh, 2011/02/14