Bash has no say about the colors that applications use, except of course what bash itself uses. Applications interact with the terminal; bash only starts them and notices when they finish.
Applications know how to talk with a terminal through the termcap (traditional) or terminfo (modeern) database. Termcap is older than colors, but terminfo does have some knowledge of colors. Look at the terminfo(5)
man page for a list of supported capabilities on your system. There's no way to specify control sequences for individual colors, but you can achieve essentially the same result by configuring the appearance of each color through the initc
capability. For example this changes the apperance of color 1 (normally red) to bright green:
tput initc 1 0 255 0
The ncurses database doesn't include this capability for terminator
or for xterm
though (as of version 5.9 on Debian jessie). However these terminal emulators (as well as any other terminal based on vte) do support an escape sequence which can be used for that purpose: OSC 4 ; c ; spec BEL
. This is how to make red into bright green:
printf '\e]4;1;#00ff00\a'
The basic colors are numbered 0–7; bold text in those colors uses colors 8–15. You can also use OSC 5 ; 0 ; spec BEL
to change the color used for bold in the default color, and so on (see the control sequence list for details).
These settings affect both foreground and backgrouns colors, there's no way to affect foreground and background separately.
To customize the appearance of colors, you would output these control sequences from your .bashrc
. That would only affect terminals where you run an interactive instance of bash, not terminals where you start another application directly.
I don't know how this interacts with Terminator's color palette settings.
bash
ish« way, asbash
is the wrong program to ask for it. The shell does not interpret output of other programs. It's the terminal emulators task to do this. If your terminal emulator cannot do this for you, you should consider replacing it by some that actually will. What kind of b0rken emulator is this Terminator-thingy‽ ;) – Andreas Wiese Mar 16 '16 at 11:45termcap
andterminfo
that are supposed to tell other programs what escape sequences to use. Thanks to http://unix.stackexchange.com/a/147/32950 I was able to do just what I want forless
- and I was hoping I could do something similar for all other programs. Unfortunately I have trouble finding good examples showing how to use termcap... – Jan Warchoł Mar 16 '16 at 14:50less
actually interprets the content it displays, resp. it actually displays it.bash
just executes commands; those commands are usually responsible for their output themselves. – Andreas Wiese Mar 16 '16 at 15:05bash
's business. But I hope that someone experienced withtermcap
can tell whether that tool can be of any help to me. – Jan Warchoł Mar 16 '16 at 15:09