-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fish doesn't understand the color white #3176
Comments
(Or, you are using Apple's "Homebrew" profile which has green for the normal text already) edit: Actually, pretty sure you need to have changed one of the ANSI whites to green to make it happen like this to you. |
@mikez302: To test if floam is right, try Also, you can pass RGB values to set_color and the color variables and fish will do the right thing (or try to). |
The important thing to keep in mind is that color names like "white" are simply mapped to the corresponding ANSI X3.64 SGR sequence. Those sequences map each color name to a number. The terminal is free to map the number to whatever color it likes and different terminals use different default colors. However, in your case I strongly suspect that @floam is correct and you've reconfigured your terminal so that "white" appears as bright green. On my terminal (iTerm2 with the default color palette) I get the expected result: |
This screenshot shows what my Terminal color settings look like: I am using the Homebrew profile. The "Text" and "Bold Text" colors are green. Everything else looks mostly like it does in @floam's screenshot. I tried running What should I do about this? It seems strange to me that fish would be unable to show white or light gray text in my terminal, if bash can do it. |
Is $fish_term24bit set to 1 somehow? |
I can't reproduce with or without setting fish_term24bit. The following screen shot is after I moved my custom fish_prompt.fish script out of the way so that I'm using the default prompt. What does |
BTW, you should configure the terminal to identify itself as |
|
OK, I had that backwards. Everywhere except for |
If you have 8 colors, these are what they are:
... and If you have a 16 color xterm the first half above still applies and the next 8 are bright variants of the above. See https://github.com/fish-shell/fish-shell/blob/master/src/color.cpp#L226-L239: rgb_color_t rgb_color_t::white() { return rgb_color_t(type_named, 7); }
static unsigned char term8_color_for_rgb(const unsigned char rgb[3]) {
const uint32_t kColors[] = {
0x000000, // Black
0xFF0000, // Red
0x00FF00, // Green
0xFFFF00, // Yellow
0x0000FF, // Blue
0xFF00FF, // Magenta
0x00FFFF, // Cyan
0xFFFFFF, // White
};
return convert_color(rgb, kColors, sizeof kColors / sizeof *kColors);
} White is color 7. He's got enough colors for white. However scroll down just a bit to Broken by this commit: 0a0acc8 When adding bright color support you can see normal-brightness There are a handful of things we could have done to make this work if we were going to get cute with the color names like this: For some reason we do not try to find the closest matching supported color for term8 or term16? And for term8 we are not willing to give them color 15 even though it will render as white. Fish doesn't appear to be taking advantage of the the RGB values we have along with each of those named colors in that struct on term256. If we wanted to we could ensure they get good colors. Instead they get the same exact thing for purple and magenta and for yellow and orange. |
See also issue #2951. Also, it's debatable that this is a bug. It's working as documented and this is the first complaint in the seven months since that change was merged. |
Actually, this is worse than what I assumed, the change didn't cause
We can't really use a lack of squeaky wheels as validation of what is or isn't a bug. Consider that this whole time we've also been locking out |
Fish assumed that you could use tparm() as long as the color is under 16 without even checking terminfo. Now, we will always let tparm take care of a color if it can. It will never use tparm if the terminal indicates a lack of support. When it cannot safely take care of this, we construct the escape ourselves Here, we no longer assume that in this case it is OK to produce a 256-color output. Add an intermediate formatter that can handle colors 0-16. Fixes issue when tparm was pushed beyond its limits: env TERM='linux' ./fish -c 'set_color --background brred | xxd' Restore harmony to ANSI color names and remove "grey". Fixes fish-shell#3176
Fish assumed that you could use tparm setaf/bg as long as the color was under 16 without even checking terminfo. Now, we will always let tparm take care of a color if it can. It will never use tparm if the terminal indicates a lack of support. When tparm cannot safely take care of this, we construct the escape ourselves. Now, fish no longer makes such a assumption, either, that it can use a fancy 256-color format for colors 0-16 when tparm can't do it natively. Add an intermediate formatter that can handle colors 0-16. That fixes the issue when tparm was pushed beyond its limits: env TERM='linux' ./fish -c 'set_color --background brred | xxd' ... and producing bogus escape output. Restores harmony to white, black ANSI color names and removes "grey". Fixes fish-shell#3176
Working to address both fish-shell#2951 and fish-shell#3176.
Fish assumed that you could use tparm setaf/bg as long as the color was under 16 without even checking terminfo. Now, we will always let tparm take care of a color if it can. It will never use tparm if the terminal indicates a lack of support. When tparm cannot safely take care of this, we construct the escape ourselves. Now, fish no longer makes such a assumption, either, that it can use a fancy 256-color format for colors 0-16 when tparm can't do it natively. Add an intermediate formatter that can handle colors 0-16. That fixes the issue when tparm was pushed beyond its limits: env TERM='linux' ./fish -c 'set_color --background brred | xxd' ... and producing bogus escape output. Restores harmony to white, black ANSI color names and removes "grey". Fixes fish-shell#3176 Move comments from output.h to output.cpp
Fish assumed that you could use tparm setaf/bg as long as the color was under 16 without even checking terminfo. Now, we will always let tparm take care of a color if it can. It will never use tparm if the terminal indicates a lack of support. When tparm cannot safely take care of this, we construct the escape ourselves. Now, fish no longer makes such a assumption, either, that it can use a fancy 256-color format for colors 0-16 when tparm can't do it natively. Add an intermediate formatter that can handle colors 0-16. That fixes the issue when tparm was pushed beyond its limits: env TERM='linux' ./fish -c 'set_color --background brred | xxd' ... and producing bogus escape output. Restores harmony to white, black ANSI color names and removes "grey". Fixes fish-shell#3176 Move comments from output.h to output.cpp
Fish assumed that you could use tparm setaf/bg as long as the color was under 16 without even checking terminfo. Now, we will always let tparm take care of a color if it can. It will never use tparm if the terminal indicates a lack of support. When tparm cannot safely take care of this, we construct the escape ourselves. Now, fish no longer makes such a assumption, either, that it can use a fancy 256-color format for colors 0-16 when tparm can't do it natively. Add an intermediate formatter that can handle colors 0-16. That fixes the issue when tparm was pushed beyond its limits: env TERM='linux' ./fish -c 'set_color --background brred | xxd' ... and producing bogus escape output. Restores harmony to white, black ANSI color names and removes "grey". Fixes fish-shell#3176 Move comments from output.h to output.cpp
Fish assumed that you could use tparm setaf/bg as long as the color was under 16 without even checking terminfo. Now, we will always let tparm take care of a color if it can. It will never use tparm if the terminal indicates a lack of support. When tparm cannot safely take care of this, we construct the escape ourselves. Now, fish no longer makes such a assumption, either, that it can use a fancy 256-color format for colors 0-16 when tparm can't do it natively. Add an intermediate formatter that can handle colors 0-16. That fixes the issue when tparm was pushed beyond its limits: env TERM='linux' ./fish -c 'set_color --background brred | xxd' ... and producing bogus escape output. Restores harmony to white, black ANSI color names and removes "grey". Fixes fish-shell#3176 Move comments from output.h to output.cpp
Fish assumed that you could use tparm setaf/bg as long as the color was under 16 without even checking terminfo. Now, we will always let tparm take care of a color if it can. It will never use tparm if the terminal indicates a lack of support. When tparm cannot safely take care of this, we construct the escape ourselves. Now, fish no longer makes such a assumption, either, that it can use a fancy 256-color format for colors 0-16 when tparm can't do it natively. Add an intermediate formatter that can handle colors 0-16. That fixes the issue when tparm was pushed beyond its limits: env TERM='linux' ./fish -c 'set_color --background brred | xxd' ... and producing bogus escape output. Restores harmony to white, brwhite, brblack, black color names Fixes fish-shell#3176 Move comments from output.h to output.cpp
Fish assumed that you could use tparm setaf/bg as long as the color was under 16 without even checking terminfo. Now, we will always let tparm take care of a color if it can. It will never use tparm if the terminal indicates a lack of support. When tparm cannot safely take care of this, we construct the escape ourselves. Now, fish no longer makes such a assumption, either, that it can use a fancy 256-color format for colors 0-16 when tparm can't do it natively. Add an intermediate formatter that can handle colors 0-16. That fixes the issue when tparm was pushed beyond its limits: env TERM='linux' ./fish -c 'set_color --background brred | xxd' ... and producing bogus escape output. Restores harmony to white, brwhite, brblack, black color names Fixes fish-shell#3176 Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs I think this should be taken care of internally.
Fish assumed that it could use could use tparm to set colors as long as the color was under 16 or max_colors from terminfo is 256 (term256_support_is_native): if (idx < 16 || term256_support_is_native()) { // Use tparm to emit color escape writembs(tparm(todo, idx); If a terminal has max_colors = 8, here is what happenened, essentially:: > env TERM=xterm tput setaf 7 | xxd 00000000: 1b5b 3337 6d .[37m > env TERM=xterm tput setaf 8 | xxd 00000000: 1b5b 3338 6d .[38m That second escape is not valid. Colors 8 through 16 ought to be \e[90m. So we replace the term256_support_is_native(), which just checked if max_colors is 256 or not, with a function that takes an argument and checks terminfo for that to see if tparm can handle it: if (term_supports_color_natively(idx) { And if that's not true, the "forced" colors no longer use this format, as this is not going to be compatible with low color terminals: else { char buff[16] = ""; snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); Add an intermediate formatter that can handle colors 0-16: else { // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. char buff[16] = ""; if (idx < 16) { snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10); } else { snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); } Restores harmony to white, brwhite, brblack, black color names. We don't want "white to refer to color color number 16, but the traditional color fish-shell#8. Fixes fish-shell#3176 Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs. Sync up our various incomplete color lists with bright hex values being given for colors 0-8. Perplexing! Using this table: http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
Fish assumed that it could use could use tparm to set colors as long as the color was under 16 or max_colors from terminfo is 256 (term256_support_is_native): if (idx < 16 || term256_support_is_native()) { // Use tparm to emit color escape writembs(tparm(todo, idx); If a terminal has max_colors = 8, here is what happenened, except it was inside fish: > env TERM=xterm tput setaf 7 | xxd 00000000: 1b5b 3337 6d .[37m > env TERM=xterm tput setaf 8 | xxd 00000000: 1b5b 3338 6d .[38m That second escape is not valid. Colors 8 through 16 ought to be \e[90m. This is what caused "white" not to work in fish-shell#3176 in Terminal.app, and obviously isn't good for real low-color terminals either. So we replace the term256_support_is_native(), which just checked if max_colors is 256 or not, with a function that takes an argument and checks terminfo for that to see if tparm can handle it. We only use this test, because otherwise, tparm should be expected to output garbage: ... /// Returns true if we think tparm can handle outputting a color index static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; } ... if (term_supports_color_natively(idx) { And if that's not true, the "forced" colors no longer use the fancy format for colors under 16, as this is not going to be compatible with the low color terminals: else { char buff[16] = ""; snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); I added an intermediate formatter that can handle colors 0-16: else { // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. char buff[16] = ""; if (idx < 16) { snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10); } else { snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); } Restores harmony to white, brwhite, brblack, black color names. We don't want "white" to refer to color color fish-shell#16, but to the standard color fish-shell#8. fish-shell#16 is "brwhite". Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs. Sync up our various incomplete color lists with bright hex values being given for colors 0-8. Perplexing! Using this table: http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html Fixes fish-shell#3176
Fish assumed that it could use could use tparm to set colors as long as the color was under 16 or max_colors from terminfo is 256 (term256_support_is_native): if (idx < 16 || term256_support_is_native()) { // Use tparm to emit color escape writembs(tparm(todo, idx); If a terminal has max_colors = 8, here is what happenened, except it was inside fish: > env TERM=xterm tput setaf 7 | xxd 00000000: 1b5b 3337 6d .[37m > env TERM=xterm tput setaf 8 | xxd 00000000: 1b5b 3338 6d .[38m That second escape is not valid. Colors 8 through 16 ought to be \e[90m. This is what caused "white" not to work in fish-shell#3176 in Terminal.app, and obviously isn't good for real low-color terminals either. So we replace the term256_support_is_native(), which just checked if max_colors is 256 or not, with a function that takes an argument and checks terminfo for that to see if tparm can handle it. We only use this test, because otherwise, tparm should be expected to output garbage: ... /// Returns true if we think tparm can handle outputting a color index static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; } ... if (term_supports_color_natively(idx) { And if that's not true, the "forced" colors no longer use the fancy format for colors under 16, as this is not going to be compatible with the low color terminals: else { char buff[16] = ""; snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); I added an intermediate formatter that can handle colors 0-16: else { // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. char buff[16] = ""; if (idx < 16) { snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10); } else { snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); } Restores harmony to white, brwhite, brblack, black color names. We don't want "white" to refer to color color fish-shell#16, but to the standard color fish-shell#8. fish-shell#16 is "brwhite". Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs. Sync up our various incomplete color lists with bright hex values being given for colors 0-8. Perplexing! Using this table: http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html Fixes fish-shell#3176
Fish assumed that it could use could use tparm to set colors as long as the color was under 16 or max_colors from terminfo is 256 (term256_support_is_native): if (idx < 16 || term256_support_is_native()) { // Use tparm to emit color escape writembs(tparm(todo, idx); If a terminal has max_colors = 8, here is what happenened, except it was inside fish: > env TERM=xterm tput setaf 7 | xxd 00000000: 1b5b 3337 6d .[37m > env TERM=xterm tput setaf 9 | xxd 00000000: 1b5b 3338 6d .[39m The first escape is good, that second escape is not valid. Bright colors should start at \e[90m: > env TERM=xterm-16color tput setaf 9 | xxd 00000000: 1b5b 3931 6d .[91m This is what caused "white" not to work in fish-shell#3176 in Terminal.app, and obviously isn't good for real low-color terminals either. So we replace the term256_support_is_native(), which just checked if max_colors is 256 or not, with a function that takes an argument and checks terminfo for that to see if tparm can handle it. We only use this test, because otherwise, tparm should be expected to output garbage: ... /// Returns true if we think tparm can handle outputting a color index static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; } ... if (term_supports_color_natively(idx) { And if that's not true, the "forced" colors no longer use the fancy format for colors under 16, as this is not going to be compatible with the low color terminals: else { char buff[16] = ""; snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); I added an intermediate formatter that can handle colors 0-16: else { // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. char buff[16] = ""; if (idx < 16) { snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10); } else { snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); } Restores harmony to white, brwhite, brblack, black color names. We don't want "white" to refer to color color fish-shell#16, but to the standard color fish-shell#8. fish-shell#16 is "brwhite". Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs. Sync up our various incomplete color lists with bright hex values being given for colors 0-8. Perplexing! Using this table: http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html Fixes fish-shell#3176
Fish assumed that it could use could use tparm to set colors as long as the color was under 16 or max_colors from terminfo is 256 (term256_support_is_native): if (idx < 16 || term256_support_is_native()) { // Use tparm to emit color escape writembs(tparm(todo, idx); If a terminal has max_colors = 8, here is what happenened, except it was inside fish: > env TERM=xterm tput setaf 7 | xxd 00000000: 1b5b 3337 6d .[37m > env TERM=xterm tput setaf 9 | xxd 00000000: 1b5b 3338 6d .[39m The first escape is good, that second escape is not valid. Bright colors should start at \e[90m: > env TERM=xterm-16color tput setaf 9 | xxd 00000000: 1b5b 3931 6d .[91m This is what caused "white" not to work in fish-shell#3176 in Terminal.app, and obviously isn't good for real low-color terminals either. So we replace the term256_support_is_native(), which just checked if max_colors is 256 or not, with a function that takes an argument and checks terminfo for that to see if tparm can handle it. We only use this test, because otherwise, tparm should be expected to output garbage: /// Returns true if we think tparm can handle outputting a color index static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; } ... if (term_supports_color_natively(idx) { And if terminfo can't do it, the "forced" colors no longer use the fancy format, when handling colors under 16, as this is not going to be compatible with the low color terminals. This looks like an escape for 256-aware terminals. else { char buff[16] = ""; snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); I added an intermediate formatter that can handle colors 0-16: else { // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. char buff[16] = ""; if (idx < 16) { snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10); } else { snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); } Restores harmony to white, brwhite, brblack, black color names. We don't want "white" to refer to color color fish-shell#16, but to the standard color fish-shell#8. fish-shell#16 is "brwhite". Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs. Sync up our various incomplete color lists and fix all color values. Colors 0-8 are assumed to be brights - e.g. red was FF0000. Perplexing! Using this table: <http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html> Fixes fish-shell#3176
Fish assumed that it could use tparm to emit escapes to set colors as long as the color was under 16 or max_colors from terminfo was 256:: if (idx < 16 || term256_support_is_native()) { // Use tparm to emit color escape writembs(tparm(todo, idx); If a terminal has max_colors = 8, here is what happenened, except inside fish: > env TERM=xterm tput setaf 7 | xxd 00000000: 1b5b 3337 6d .[37m > env TERM=xterm tput setaf 9 | xxd 00000000: 1b5b 3338 6d .[39m The first escape is good, that second escape is not valid. Bright colors should start at \e[90m: > env TERM=xterm-16color tput setaf 9 | xxd 00000000: 1b5b 3931 6d .[91m This is what caused "white" not to work in fish-shell#3176 in Terminal.app, and obviously isn't good for real low-color terminals either. So we replace the term256_support_is_native(), which just checked if max_colors is 256 or not, with a function that takes an argument and checks terminfo for that to see if tparm can handle it. We only use this test, because otherwise, tparm should be expected to output garbage: /// Returns true if we think tparm can handle outputting a color index static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; } ... if (term_supports_color_natively(idx) { And if terminfo can't do it, the "forced" escapes no longer use the fancy format when handling colors under 16, as this is not going to be compatible with low color terminals. The code before used: else { char buff[16] = ""; snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); I added an intermediate format for colors 0-15: else { // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. char buff[16] = ""; if (idx < 16) { snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10); } else { snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); } Restores harmony to white, brwhite, brblack, black color names. We don't want "white" to refer to color color fish-shell#16, but to the standard color fish-shell#8. fish-shell#16 is "brwhite". Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs. Sync up our various incomplete color lists and fix all color values. Colors 0-8 are assumed to be brights - e.g. red was FF0000. Perplexing! Using this table: <http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html> Fixes fish-shell#3176
Fish assumed that it could use tparm to emit escapes to set colors as long as the color was under 16 or max_colors from terminfo was 256:: if (idx < 16 || term256_support_is_native()) { // Use tparm to emit color escape writembs(tparm(todo, idx); If a terminal has max_colors = 8, here is what happenened, except inside fish: > env TERM=xterm tput setaf 7 | xxd 00000000: 1b5b 3337 6d .[37m > env TERM=xterm tput setaf 9 | xxd 00000000: 1b5b 3338 6d .[39m The first escape is good, that second escape is not valid. Bright colors should start at \e[90m: > env TERM=xterm-16color tput setaf 9 | xxd 00000000: 1b5b 3931 6d .[91m This is what caused "white" not to work in fish-shell#3176 in Terminal.app, and obviously isn't good for real low-color terminals either. So we replace the term256_support_is_native(), which just checked if max_colors is 256 or not, with a function that takes an argument and checks terminfo for that to see if tparm can handle it. We only use this test, because otherwise, tparm should be expected to output garbage: /// Returns true if we think tparm can handle outputting a color index static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; } ... if (term_supports_color_natively(idx) { And if terminfo can't do it, the "forced" escapes no longer use the fancy format when handling colors under 16, as this is not going to be compatible with low color terminals. The code before used: else { char buff[16] = ""; snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); I added an intermediate format for colors 0-15: else { // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. char buff[16] = ""; if (idx < 16) { snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10); } else { snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); } Restores harmony to white, brwhite, brblack, black color names. We don't want "white" to refer to color color fish-shell#16, but to the standard color fish-shell#8. fish-shell#16 is "brwhite". Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs. Sync up our various incomplete color lists and fix all color values. Colors 0-8 are assumed to be brights - e.g. red was FF0000. Perplexing! Using this table: <http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html> Fixes fish-shell#3176
Fish assumed that it could use tparm to emit escapes to set colors as long as the color was under 16 or max_colors from terminfo was 256. Now only uses tparm if max_colors indicates support. Otherwise, use improved ability to generate color escapes ourselves. This is what caused "white" not to work in TERM=xterm on Terminal.app, and obviously isn't good for real low-color terminals either. Fixes fish-shell#3176 Restores harmony to color white. Adds brwhite, brblack. Nukes the config.fish set_color hack for linux VTs. Fixes fish-shell#2951
I've just updated fish and I've got the same problem... I've switch to grey, but for me it's a regression. |
Wow, sorry about those mentions above the prior comment spamming this thread. Moral of the story: don't add the "Fixes: " line until right before you push to master. |
I finally got a chance to try these things. This is what I have found:
I then went into my advanced settings and changed the "Declare terminal as" setting to "xterm-256color". Now, Out of curiosity, why isn't the terminal declared as "xterm-256color" by default? Will changing this setting cause any problems? |
On OS X it has defaulted to Is it possible you have migrated along with you some old settings over from a few versions of OS X ago, as you have upgraded? You could test by reverting one of the profiles/"themes" in Terminal.app to default with the button it has and see what setting it gets. |
@floam, to be honest, I don't care enough to spend my time trying to figure out why that happened. Maybe you are right about the default. I changed the setting to |
No problem, just a suggestion if you were curious 😄 This should be left open - the bug you encountered is a regression in fish that I'm working on fixing in #3260. Your changing that there should get you 256 colors and sidestep this bug - but this is a problem that shouldn't occur even only with 8 colors supported. |
Fish assumed that it could use tparm to emit escapes to set colors as long as the color was under 16 or max_colors from terminfo was 256:: if (idx < 16 || term256_support_is_native()) { // Use tparm to emit color escape writembs(tparm(todo, idx); If a terminal has max_colors = 8, here is what happenened, except inside fish: > env TERM=xterm tput setaf 7 | xxd 00000000: 1b5b 3337 6d .[37m > env TERM=xterm tput setaf 9 | xxd 00000000: 1b5b 3338 6d .[39m The first escape is good, that second escape is not valid. Bright colors should start at \e[90m: > env TERM=xterm-16color tput setaf 9 | xxd 00000000: 1b5b 3931 6d .[91m This is what caused "white" not to work in fish-shell#3176 in Terminal.app, and obviously isn't good for real low-color terminals either. So we replace the term256_support_is_native(), which just checked if max_colors is 256 or not, with a function that takes an argument and checks terminfo for that to see if tparm can handle it. We only use this test, because otherwise, tparm should be expected to output garbage: /// Returns true if we think tparm can handle outputting a color index static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; } ... if (term_supports_color_natively(idx) { And if terminfo can't do it, the "forced" escapes no longer use the fancy format when handling colors under 16, as this is not going to be compatible with low color terminals. The code before used: else { char buff[16] = ""; snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); I added an intermediate format for colors 0-15: else { // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. char buff[16] = ""; if (idx < 16) { snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10); } else { snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx); } Restores harmony to white, brwhite, brblack, black color names. We don't want "white" to refer to color color fish-shell#16, but to the standard color fish-shell#8. fish-shell#16 is "brwhite". Move comments from output.h to output.cpp Nuke the config.fish set_color hack for linux VTs. Sync up our various incomplete color lists and fix all color values. Colors 0-8 are assumed to be brights - e.g. red was FF0000. Perplexing! Using this table: <http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html> Fixes fish-shell#3176
I would like the current directory in my fish prompt to be light gray, as it was in bash before I started using fish. I tried running
set -U fish_color_cwd white
(since white is the closest color to light gray that is listed in theset_color
documentation) and it didn't do anything. The text was green after, just like it was before.I then tried
set -U fish_color_cwd red
to see what happened and the text turned red, like I expected. Then I triedset -U fish_color_cwd white --bold
and it became bold, but green again. It seems like it understands all of the colors I tried, but not white.I am using fish 2.3.0 on OS X 10.11.5 and the built-in Terminal. Here is a screenshot demonstrating what is happening:
![white not working in fish shell](https://cloud.githubusercontent.com/assets/510781/16399572/9674a980-3c88-11e6-9b11-76d5379e1450.png)
The text was updated successfully, but these errors were encountered: