akinomyoga / ble.sh

Bash Line Editor―a line editor written in pure Bash with syntax highlighting, auto suggestions, vim modes, etc. for Bash interactive sessions.
BSD 3-Clause "New" or "Revised" License
2.33k stars 77 forks source link

I don't want BLE to change my terminal colors. How do i do that? #404

Closed ToontjeM closed 4 months ago

ToontjeM commented 4 months ago

iterm2 on Mac. iTerm has its own terminal themes. I don't want BLE to overwrite the colors set by iTerm. How do i do that?

akinomyoga commented 4 months ago

Could you explain it in more detail? First of all, ble.sh does not change the terminal colors, so you should be describing something other as terminal colors, which I'm not sure about.

Or one possibility is that terminfo/termcap reports the supported number of the current terminal to be less than the actual number. For example, when terminfo/termcap says the supported number of colors is 8 but your prompt uses unsupported colors, ble.sh replaces the unsupported colors with the closest color assuming the standard 16 color palette. If terminfo reports a smaller number than the actual, even supported numbers are replaced. What are the results of the following command?

$ echo "$TERM"
$ tput colors || tput Co
ToontjeM commented 4 months ago

When I press Tab I get a menu of files and folders in the directory I am at. The color of the names of the files and folders are, as far as I understand, defined by ble.sh. I want to keep the colors I set in my terminal program, I don’t want ble to color anything.

akinomyoga commented 4 months ago

Thank you for the explanation.

When I press Tab I get a menu of files and folders in the directory I am at. The color of the names of the files and folders are, as far as I understand, defined by blue.sh.

Yes, your understanding is correct if "blue.sh" is a typo of "ble.sh". (Or is "blue.sh" another script to make everything blue?)

I want to keep the colors I set in my terminal program,

I'm confused. The colors of the files and folders in the menu are not set by the terminal even if ble.sh doesn't do anything. Or is your terminal a special terminal that colors everything at the terminal level?

I don’t want ble to color anything.

I'm not sure if I correctly understand it, but does the following setting produce the results that you intend?

_ble_term_colors=0
bleopt term_index_colors=0
bleopt term_true_colors=0

If not, I'd appreciate it if you could explain the desired behavior in more detail.

akinomyoga commented 4 months ago

Or another possibility is that you actually want ble.sh to color files and folders, but by only using the colors from the terminal's 16 colors. In such a case, you can use the following setting:

bleopt term_index_colors=0
bleopt term_true_colors=0

There seems to be some confusion, so I need to explain the colors used by terminals and terminal applications. First, the terminal and the terminal applications are separate programs. The terminals or terminal emulators (including iTerm2) are something like just a canvas to render texts and a window to accept user inputs. The terminal applications (including shells and other programs including ble.sh) are programs that tell the terminals what text should be drawn by which colors. The point is that the color of each piece of texts is specified by the terminal applications (using some schemes) but not by the terminals. In this sense, if you force ble.sh to color nothing, everything is drawn without colors. However, a terminal can interpret the color specification by the terminal applications in its own way, which is the terminal's themes. To roughly categorize the color specifications of the output texts to modern terminals, there are three different schemes.

ble.sh by default uses the first and the second schemes as far as the terminfo/termcap database associated with the environment variable TERM reports the supported number of colors as 256 (or 88). The third one is only used when the user specifies the colors in the ble.sh setting using the RGB specification. If you want to make ble.sh only use the first scheme (whose palette is controlled by the terminal's theme), you can turn off the second scheme by setting bleopt term_index_colors=0. In case the colors are specified by the RGB values in some ble.sh settings, one can also explicitly turn off the third scheme by bleopt term_true_colors=0.

ToontjeM commented 4 months ago

When I press Tab I get a menu of files and folders in the directory I am at. The color of the names of the files and folders are, as far as I understand, defined by blue.sh.

Yes, your understanding is correct if "blue.sh" is a typo of "ble.sh". (Or is "blue.sh" another script to make everything blue?)

Yeah, that was my auto-correct on my phone kicking in.

I want to keep the colors I set in my terminal program,

I'm confused. The colors of the files and folders in the menu are not set by the terminal even if ble.sh doesn't do anything. Or is your terminal a special terminal that colors everything at the terminal level?

I am using iTerm2 which has themes. I call themes "colors" because that's basically what they are.

I don’t want ble to color anything.

I'm not sure if I correctly understand it, but does the following setting produce the results that you intend?

I want ble.sh to leave the colors as set by the iTerm2 theme because this looks terrible:

image

I want it to look like as if i was not using ble.sh: image

ToontjeM commented 4 months ago

Using bleopt term_index_colors=0 i have it almost the way i want. Now i just need to get rid of the underlines.

Edit: Ok, i got what i want using

bleopt term_index_colors=0

ble-face command_directory=fg=26
ble-face filename_block=fg=yellow,bg=black
ble-face filename_character=fg=white,bg=black
ble-face filename_directory=fg=26
ble-face filename_directory_sticky=fg=white,bg=26
ble-face filename_executable=fg=green
ble-face filename_link=fg=teal
ble-face filename_orphan=fg=teal,bg=224
ble-face filename_other=
ble-face filename_pipe=fg=lime,bg=black
ble-face filename_setgid=fg=black,bg=191
ble-face filename_setuid=fg=black,bg=220
ble-face filename_socket=fg=cyan,bg=black
ble-face filename_url=fg=blue
ble-face filename_warning=fg=red
akinomyoga commented 4 months ago

I want it to look like as if i was not using ble.sh:

OK, so you want it to make it similar to the output of ls. First of all, the ls command is a separate program unrelated to the terminal or ble.sh. The list by ls and the list by ble.sh are unrelated. ble.sh generates the list without help of the ls command or the help of the terminal.

There are two ways to make the highlighting similar to the output of ls.

One way is to specify the colors one by one by yourself. You can check the list of the current setting by

$ ble-face filename_@
ble-face filename_block=fg=yellow,bg=black,underline
ble-face filename_character=fg=white,bg=black,underline
ble-face filename_directory=fg=26,underline
ble-face filename_directory_sticky=fg=white,bg=26,underline
ble-face filename_executable=fg=green,underline
ble-face filename_link=fg=teal,underline
ble-face filename_ls_colors=none
ble-face filename_orphan=fg=teal,bg=224,underline
ble-face filename_other=underline
ble-face filename_pipe=fg=lime,bg=black,underline
ble-face filename_setgid=fg=black,bg=191,underline
ble-face filename_setuid=fg=black,bg=220,underline
ble-face filename_socket=fg=cyan,bg=black,underline
ble-face filename_url=fg=blue,underline
ble-face filename_warning=fg=red,underline

You can reset those faces with the underline removed from their values. Ah, OK. It seems you have already found out it by yourself.

ToontjeM commented 4 months ago

But i think the default should be to not touch the original colors and let the user adjust what they want. Anyway, all good. You can close the issue.

akinomyoga commented 4 months ago

Another way is, if you have the LS_COLORS environment variable, you can do

ble-face filename_@=none
bleopt filename_ls_colors="$LS_COLORS"

Or if the environment variable LS_COLORS does not exist but the program dircolors exists, you can load LS_COLORS by evaluating the output of the command dircolors:

eval "$(dircolors)"
ble-face filename_@=none
bleopt filename_ls_colors="$LS_COLORS"
akinomyoga commented 4 months ago

But i think the default should be to not touch the original colors and let the user adjust what they want.

The original colors do not exist. The colors you refer to are the custom colors specified by the ls command in your system. The colors of ls depend on the implementation, the system, and the configuration by the users, and there is no standard for the colors of the ls command. So I'm not sure what to do even if we decided to follow the ls command. Also, ble.sh is a separate program unrelated to the ls command, which does not use the output of the ls command. I don't feel I need to follow the colors of another unrelated program.

akinomyoga commented 4 months ago

I'm closing it. Thank you for trying ble.sh out!