Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11416
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Chet Ramey <chet.ramey@case.edu> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: [Bug-readline] Fwd: Re: Feature proposal/request: input line highlighting |
| Date | Fri, 21 Aug 2015 13:46:29 -0400 |
| Lines | 53 |
| Sender | Chet Ramey <chet@caleb.local> |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.34.1440182706.11330.bug-bash@gnu.org> (permalink) |
| References | <5579B2EF.5040101@computer.org> <20150612073736.GB13625@vapier> <917369538.27702.1434100972495.JavaMail.open-xchange@oxbsltgw09.schlund.de> <557AA6C9.2@computer.org> |
| Reply-To | chet.ramey@case.edu |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | usenet.stanford.edu 1440182707 20489 208.118.235.17 (21 Aug 2015 18:45:07 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-readline@gnu.org, bug-bash@gnu.org, chet@po.cwru.edu |
| To | towo@computer.org |
| Envelope-to | bug-bash@gnu.org |
| In-Reply-To | Message from towo@computer.org of Fri, 12 Jun 2015 11:30:49 +0200 (id <557AA6C9.2@computer.org>) |
| Read-Receipt-To | chet.ramey@case.edu |
| X-Junkmail-Status | score=10/50, host=mpv6.cwru.edu |
| X-Junkmail-Whitelist | YES (by domain whitelist at mpv2.tis.cwru.edu) |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] |
| X-Received-From | 129.22.105.37 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.14 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:11416 |
Show key headers only | View raw
> >> On 11 Jun 2015 18:10, Thomas Wolff wrote:
> >> > as opposed to having a fancy colored prompt, I would like to be
> >> able to
> >> > set up coloring of the whole bash command input line (but not the
> >> > following command output). This could be achieved by adding a variable
> >> > like "AFTERPROMPT_COMMAND" which is executed after a prompt line is
> >> > completed (or "PS9" which is output after a prompt line is completed).
> >> > It could even be a nice idea to configure this behavior separately for
> >> > bash and readline, so the users have a choice whether to color just
> >> > command input, readline-handled program input, or both.
> >> > I would appreciate this feature, and maybe even supply a patch if I
> >> had
> >> > a clue where to hook it in...
> >>
> >> this is already doable -- leave the end of PS1 enabling color.
> >> PS1='\[\e[0;33m\]$ \[\e[34;1m\]'
> >>
> >> this will color the input buffer blue
> thanks for your response, but that's not what I meant because the output
> of the invoked programs will stay blue. I'll illustrate my idea with the
> attached screenshot, showing a few possible options.
So the problem is reduced to restoring the normal color before any invoked
program has a chance to produce output.
There are a couple of ways to do it using bash-specific functionality.
Using only readline is hard because readline doesn't really have anything
that just prints text to the terminal -- it's designed to manage an input
buffer.
This bash-specific one is easiest to describe.
1. Append the character sequence that changes the terminal to the desired
color to PS1, making sure to bracket it correctly:
PS1='\u@\h\$ \[\e1;34m\]'
2. Define a DEBUG trap that will restore the default terminal color settings
before invoking a command:
trap -- 'printf "\e[0m"' DEBUG
There are ways to make this work using `bind -x' and readline's key binding
to macros, but that is much more complicated.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: [Bug-readline] Fwd: Re: Feature proposal/request: input line highlighting Chet Ramey <chet.ramey@case.edu> - 2015-08-21 13:46 -0400
csiph-web