Change colors on executable files in the terminal

2019-06-06 11:46发布

问题:

How do I change it, so executable files don't have another color, compared to other files? I'm on macOS Sierra (10.12.6). It's the same, both in the regular Terminal:

... or in iTerm2:

It's frustating to look at. If i write chmod -x [FILENAME] then it disappears. But I don't want to change if the files are executable or not, - I want to change the color of executable files. I want my files to look like this (regardless of if it's executable or not):

回答1:

I tried correcting Anshuman's answer, so it could help people with the potential same challenges. His answer pointed me in the right direction, but was pretty far from the answer to the question. So I'll post it here myself.

The LSCOLORS are set in your ~/.bash_profile (or ~/.zshrc-file, if you use Zshell) for your environment. On this page, then you can experiment a bit with the settings and see which letters changes which colors. It's in your current LSCOLORS that it's setting the color of your executable files to be another color. Here's how you find (and change) that color:

Go to your terminal and write:

echo $LSCOLORS

then it'll print out your current setup, which might be something along these lines:

Gxfxcxdxbxegedabagacad

If you then (in this case) change it to this:

GxfxcxdxDxegedabagacad

Then it would change the colors of the executable files. And what that change comes down to, is which color in your profile, it's pointing to:



回答2:

set the LSCOLORS environment variable create an alias for ls so that it shows colors by default In your ~/.bash_profile add the following:

export LSCOLORS="EHfxcxdxBxegecabagacad"

alias ls='ls -lGH' <-----This shows in list format, follow symlinks colorized