Change colors on executable files in the terminal (or iTerm2)

7.7k views Asked by At

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:

Terminal executable files - color red

... or in iTerm2:

iTerm2 executable files - red color

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):

Usual iTerm2 colors

4

There are 4 answers

0
Zeth On BEST ANSWER

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:

colors in iTerm2

0
Anshuman panwar On

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

0
Carlos Leonardo Camilo Vargas On

If you want to highlight or put some colors to the binary files in the terminal. You can install https://github.com/ohmyzsh/ohmyzsh and then install some of these https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes

0
Adam D. On

Another way to handle this problem is to simply override "ls --color" altogether, I recently solved this problem with a simple awk script and shell wrapper called "cf".

Then you can create alias for ls like this:

alias ls='_(){ /bin/ls -F -1 -A "$@"|cf|column;};_'

See screenshots and get it from: GitHub
It also has a deb installer