mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-28 20:34:07 +08:00
set_color: Print the given colors with --print-colors
This commit is contained in:
parent
0a73b182c0
commit
98ba66ed8e
|
@ -32,7 +32,7 @@ The following options are available:
|
||||||
Sets the background color.
|
Sets the background color.
|
||||||
|
|
||||||
**-c** or **--print-colors**
|
**-c** or **--print-colors**
|
||||||
Prints a list of the 16 named colors.
|
Prints the given colors or a colored list of the 16 named colors.
|
||||||
|
|
||||||
**-o** or **--bold**
|
**-o** or **--bold**
|
||||||
Sets bold mode.
|
Sets bold mode.
|
||||||
|
|
|
@ -63,10 +63,11 @@ static void print_modifiers(outputter_t &outp, bool bold, bool underline, bool i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_colors(io_streams_t &streams, bool bold, bool underline, bool italics, bool dim,
|
static void print_colors(io_streams_t &streams, wcstring_list_t args, bool bold, bool underline, bool italics, bool dim,
|
||||||
bool reverse, rgb_color_t bg) {
|
bool reverse, rgb_color_t bg) {
|
||||||
outputter_t outp;
|
outputter_t outp;
|
||||||
for (const auto &color_name : rgb_color_t::named_color_names()) {
|
if (args.empty()) args = rgb_color_t::named_color_names();
|
||||||
|
for (const auto &color_name : args) {
|
||||||
if (!streams.out_is_redirected && isatty(STDOUT_FILENO)) {
|
if (!streams.out_is_redirected && isatty(STDOUT_FILENO)) {
|
||||||
print_modifiers(outp, bold, underline, italics, dim, reverse, bg);
|
print_modifiers(outp, bold, underline, italics, dim, reverse, bg);
|
||||||
rgb_color_t color = rgb_color_t(color_name);
|
rgb_color_t color = rgb_color_t(color_name);
|
||||||
|
@ -182,7 +183,8 @@ maybe_t<int> builtin_set_color(parser_t &parser, io_streams_t &streams, const wc
|
||||||
if (bgcolor && bg.is_special()) {
|
if (bgcolor && bg.is_special()) {
|
||||||
bg = rgb_color_t(L"");
|
bg = rgb_color_t(L"");
|
||||||
}
|
}
|
||||||
print_colors(streams, bold, underline, italics, dim, reverse, bg);
|
wcstring_list_t args(argv + w.woptind, argv + argc);
|
||||||
|
print_colors(streams, args, bold, underline, italics, dim, reverse, bg);
|
||||||
return STATUS_CMD_OK;
|
return STATUS_CMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,3 +82,13 @@ expect_str("\n\x1b[37mwhite")
|
||||||
expect_str("\n\x1b[33myellow")
|
expect_str("\n\x1b[33myellow")
|
||||||
expect_str("normal")
|
expect_str("normal")
|
||||||
expect_prompt()
|
expect_prompt()
|
||||||
|
|
||||||
|
# ENABLE RGB MODE - turn this off if you want to test anything after this!
|
||||||
|
sendline("set -g fish_term24bit 1")
|
||||||
|
expect_prompt()
|
||||||
|
|
||||||
|
# See that --print-colors prints the given colors.
|
||||||
|
sendline("set_color --print-colors ff0 red")
|
||||||
|
expect_str("\x1b[38;2;255;255;0mff0")
|
||||||
|
expect_str("\x1b[31mred")
|
||||||
|
expect_prompt()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user