[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] `read -e -p`, colors, and invisible chars
From: |
Mike Frysinger |
Subject: |
Re: [Help-bash] `read -e -p`, colors, and invisible chars |
Date: |
Wed, 26 Aug 2015 22:16:16 -0400 |
On 26 Aug 2015 22:04, Chet Ramey wrote:
> On 8/26/15 9:01 PM, Mike Frysinger wrote:
> > my desire is simple:
> > show a custom colorized prompt when reading input and leverage readline
> > (for editing & history)
> >
> > the `read` builtin almost gets me there:
> > - the -p flag allows you to specify a custom prompt
> > - the -e flag uses readline for input
> >
> > however, the -p flag does not parse escape sequences. np, just expand
> > that myself ahead of time using `printf %b`. simple example:
> > prompt=$(printf '%bfoo>%b ' '\033[1;33m' '\033[0m')
> > read -e -p "${prompt}"
> >
> > now i hit the classic invisible char problem when readline tries to
> > redraw the prompt (just hold up on the arrow key to draw many lines
> > from your history). normally i'd leverage \[ and \], but bash does
> > not seem to support that w/the read builtin -- they get rendered in
> > the output directly instead of being consumed.
> > $ prompt=$(printf '%bfoo>%b ' '\[\033[1;33m\]' '\[\033[0m\]')
> > $ read -e -p "${prompt}"
> > \[\]foo>\[\]
> > (yes, moving the \[ and \] to the printf string yields same behavior)
>
> https://lists.gnu.org/archive/html/bug-bash/2015-08/msg00025.html
so no interest in making -p easier to use ?
can we at least extend the read -p section in the man page ?
and add tips in the PROMPTING section ?
-mike
signature.asc
Description: Digital signature
- [Help-bash] `read -e -p`, colors, and invisible chars, Mike Frysinger, 2015/08/26
- Re: [Help-bash] `read -e -p`, colors, and invisible chars, Dennis Williamson, 2015/08/26
- Re: [Help-bash] `read -e -p`, colors, and invisible chars, Chet Ramey, 2015/08/26
- Re: [Help-bash] `read -e -p`, colors, and invisible chars,
Mike Frysinger <=