mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-02 18:00:49 +02:00
readline: use a custom extension in LS_COLORS to set the colored completion prefix, if present
This commit is contained in:
+18
-1
@@ -73,6 +73,8 @@
|
||||
static bool is_colored (enum indicator_no type);
|
||||
static void restore_default_color (void);
|
||||
|
||||
#define RL_COLOR_PREFIX_EXTENSION "readline-colored-completion-prefix"
|
||||
|
||||
COLOR_EXT_TYPE *_rl_color_ext_list = 0;
|
||||
|
||||
/* Output a color indicator (which may contain nulls). */
|
||||
@@ -110,13 +112,28 @@ _rl_set_normal_color (void)
|
||||
}
|
||||
}
|
||||
|
||||
static struct bin_str *
|
||||
_rl_custom_readline_prefix (void)
|
||||
{
|
||||
size_t len;
|
||||
COLOR_EXT_TYPE *ext;
|
||||
|
||||
len = strlen (RL_COLOR_PREFIX_EXTENSION);
|
||||
for (ext = _rl_color_ext_list; ext; ext = ext->next)
|
||||
if (ext->ext.len == len && STREQ (ext->ext.string, RL_COLOR_PREFIX_EXTENSION))
|
||||
return (&ext->seq);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
_rl_print_prefix_color (void)
|
||||
{
|
||||
struct bin_str *s;
|
||||
|
||||
/* What do we want to use for the prefix? Let's try cyan first, see colors.h */
|
||||
s = &_rl_color_indicator[C_PREFIX];
|
||||
s = _rl_custom_readline_prefix ();
|
||||
if (s == 0)
|
||||
s = &_rl_color_indicator[C_PREFIX];
|
||||
if (s->string != NULL)
|
||||
{
|
||||
if (is_colored (C_NORM))
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet.ramey@case.edu
|
||||
.\"
|
||||
.\" Last Change: Wed Jun 16 09:49:37 EDT 2021
|
||||
.\" Last Change: Mon Nov 15 17:06:54 EST 2021
|
||||
.\"
|
||||
.TH READLINE 3 "2021 June 16" "GNU Readline 8.1"
|
||||
.TH READLINE 3 "2021 November 15" "GNU Readline 8.1"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
@@ -359,6 +359,9 @@ If set to \fBOn\fP, when listing completions, readline displays the
|
||||
common prefix of the set of possible completions using a different color.
|
||||
The color definitions are taken from the value of the \fBLS_COLORS\fP
|
||||
environment variable.
|
||||
If there is a color definition in \fB$LS_COLORS\fP for the custom suffix
|
||||
"readline-colored-completion-prefix", readline uses this color for
|
||||
the common prefix instead of its default.
|
||||
.TP
|
||||
.B colored\-stats (Off)
|
||||
If set to \fBOn\fP, readline displays possible completions using different
|
||||
|
||||
@@ -445,6 +445,9 @@ If set to @samp{on}, when listing completions, Readline displays the
|
||||
common prefix of the set of possible completions using a different color.
|
||||
The color definitions are taken from the value of the @env{LS_COLORS}
|
||||
environment variable.
|
||||
If there is a color definition in @env{LS_COLORS} for the custom suffix
|
||||
@samp{readline-colored-completion-prefix}, Readline uses this color for
|
||||
the common prefix instead of its default.
|
||||
The default is @samp{off}.
|
||||
|
||||
@item colored-stats
|
||||
|
||||
@@ -4,7 +4,7 @@ Copyright (C) 1988-2021 Free Software Foundation, Inc.
|
||||
|
||||
@set EDITION 8.1
|
||||
@set VERSION 8.1
|
||||
@set UPDATED 16 June 2021
|
||||
@set UPDATED-MONTH June 2021
|
||||
@set UPDATED 15 November 2021
|
||||
@set UPDATED-MONTH November 2021
|
||||
|
||||
@set LASTCHANGE Wed Jun 16 09:50:11 EDT 2021
|
||||
@set LASTCHANGE Mon Nov 15 17:05:28 EST 2021
|
||||
|
||||
Reference in New Issue
Block a user