So I followed this thread (Changing terminal color) and got all of the colors working for directories and such, except however, for normal files such as a Gemfile or .txt files or .java files or .rb files etc… I was wondering how I can get normal files to show up in color, even better if I can get different extensions of the file to show up in different colors as well. Let me know if you guys have any resources for this.
MacOS – Changing terminal colors for normal files when ls -G or within .bash_profile
bashcolormacosterminal
Related Question
- More colors than ls -G in file extensions
- MacOS – Terminal not displaying colors for directory listings
- Colors by file type in terminal (running bash)
- MacBook – How to get different colors for directories, etc. in iTerm2
- MacBook – Wrong factory display callibration for MacBook Pro 2016 15″
- Grc inside terminal (with different colors into terminal as a function of files size) not working on 10.14.6 Mojave and working on High Sierra 10.13.6
- MacBook – Occasional low contrast on external display when waking MacBook Pro from sleep
Best Answer
I don't think colorizing the file names of regular files is possible with
ls
alone (i.e. without postprocessing the output with another script):The manual page for
ls
(shown when you typeman ls
) does not mention this possibility.I would expect that the
ls
coming with Mac OS X is very similar to the BSD version ofls
, since there seems to be little motivation for Apple to make changes in this area. The source code for BSD'sls
is available online, e.g. the FreeBSD version is on GitHub. The function which selects the color for a file name iscolortype()
in the source filebin/ls/print.c
. And checking the source code it is clear that at least the BSD version ofls
does not have the ability to change color when printing the names of a regular file.