You are not logged in.
I am using st and I want to change colors in terminal by myself. How can I figure out what color (out of 16 given in config.def.h) refers to what kind of file (symlink, dir, etc.)?
I have changed some of them already and figured what option changes directories color but I would like to know how to see the colors (currently used) for all types.
Offline
This isn't really clear. If you mean the colors in the output of `ls` then this is set by the environment variable LS_COLORS. You can use `dircolors` to see the current settings. But these are not in html color codes, these are in the terminal's 256 colors. If you want to change the html/hex rgb value of the 256 colors, this is done in your terminal, in your case in st's config.h.
If you are changing your config.h (or config.def.h) to make the ls output what you want, I'd say you are doing it wrong. While you *can* set the top 16 colors to whatever you want there is an expectation by many tools that 1/9 are red or redish, 2/10 green, 3/11 yellow, etc. You should set these to shades of these colors that you find pleasant. If you want to change the color of directories, or any other filetype highlighted by `ls` then use LS_COLORS. You can specify not only one of the 16 colors, but any of the 256 color cube.
Last edited by Trilby (2020-04-20 16:59:19)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Thank you for reply. It is first time I am trying to do something like this so I don't know much about it. I don't quite understand why I can't set whatever colors I want as long as it is readable.
echo $LS_COLORSgives nothing but
dircolorsgives LS_COLORS='rs=0:di=01;34 ... which is usual output and as far as I understand di=01;34 means that directories are blue and with no background. This is the thing in tty. When I am in st, directories are colored red (I have set it myself in st's config.def.h). My problem is - there is a lot of color schemes for st and it is just 16 colors one sets in config.h or via Xresources and I want to create my own scheme but cant understand what color refers to what.
Offline
as far as I understand di=01;34 means that directories are blue and with no background.
This means bold (the 1) and foreground color 4 (34). This is only blue if the standards are followed which you are trying to break.
If you want directories to appear red, I'd strongly discourage you from making color 4 a shade or red. Instead, just change LS_COLORS so that directories are d=1;31 or some other red color (e.g. d=1;38;5;196).
My problem is - there is a lot of color schemes for st and it is just 16 colors one sets in config.h or via Xresources and I want to create my own scheme but cant understand what color refers to what.
You can set as many colors as you'd like in st's config.h, but you really shouldn't set colors higher than 16, and even those below 16 should stick with variations on the expected colors. There is a wide range of 16-color colorschemes, but you'll notice that an exceedingly vast majority of them still have some redish color for 1 and 9, some shade of green for 2 and 10, etc.
But as for knowing which of the 256 colors is assoicated with which filetype, that is in the LS_COLORS produced by dircolors. But you are thinking about it backwards. Don't find that executable files are set to color 2 then try to change what color 2 is in st. Instead, change LS_COLORS so that executable files are colored the way you want.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Thanks a lot for the explanation, now it is clear. I still want to modify config rather than ls_colors, because it is easier if there are multiple schemes. Besides changing ls_colors affects tty terminal too which i don't want to do.
Offline
Ah ... none of that adds up.
You can have multiple files specifying LS_COLORS that you can read to take immediate effect whenever you want. Changing the theme in st requires recompiling and reinstalling. You can also set colors for specific terminals, and not make any changes at all for the tty simply by not running dircolors or specifying LS_COLORS in those environments. E.g. in a shellrc:
case $TERM in
linux) ;; # do nothing
xterm) dircolors ~/.xterm.colors ;;
*) dircolors ~/.other.colors ;;
esacOr if you prefer not even using dircolors:
case $TERM in
linux) ;;
xterm) export LS_COLORS='di=01;31:...' ;;
*) export LS_COLORS='di=01;32:...' ;;
esacLast edited by Trilby (2020-04-20 20:24:42)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
I don't have to recompile if I am doing it via Xresources. Why is it preferable to change colors with LS_COLORS and not certain terminal config? Both ways looks rather simple.
Last edited by Anonymous2020 (2020-04-20 21:03:10)
Offline
Are you using a patched version of st? St doesn't use xresources. But that's really not important. In any case, it's definitely not harder to change LS_COLORS, and it is the correct way to specify colors for ls - but I'm just being a broken record here, you're going to do what you want.
As to why it's preferable:
1) you can actually specify colors for file types which was your initial goal. If you just change the 16 primary terminal colors, you're still stuck with the default dircolors "groupings". For example, the default dircolors might have two different file types using the same color (e.g., color 5); you can change how color 5 is displayed in your terminal, but those two filetypes would still show up as the same color. If, instead, you modify dircolors, you can specify different colors for each filetype.
2) and much more importantly, changing dircolors/LS_COLORS will not screw up other terminal programs. As I've said several times, colors 1/9 are expected to be shades or red, 2/10 green, etc. Countless programs configs will use color names. For example, in mutt if you specify that something should be "red" your muttrc may say red but it will show up as green, or whatever you specified color 1 to be in your terminal. This would be confusing and will make it harder to customize other programs.
Last edited by Trilby (2020-04-20 21:18:09)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
I see. Will there be any conflicts like the one you describe If I keep the default colors and just change their shades?
Offline
No, as I've described, that's what you should do. There is nothing suggesting a specific shade of red for color 1, just that color 1 is (by de facto standard) some sort of "red".
But note also with LS_COLORS / dircolors, you can use any of the 256 colors - you are not limited to the top 16. Here's the color preview script I use:
#!/bin/sh
for i in $(seq 0 255); do
printf '\033[0;48;5;%sm %03d\033[0;38;5;%sm %03d ' $i $i $i $i
case $i in 15|231) printf \\n\\n;; 7|239|247|255) printf \\n;; esac
[ $i -gt 15 ] && [ $i -lt 231 ] && [ $(((i-15) % 6)) -eq 0 ] && printf \\n
done ||:"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Thank you for the explanation.
Offline