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

血红的双手。 提交于 2020-01-13 11:06:11

问题


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




回答3:


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



来源:https://stackoverflow.com/questions/46322955/change-colors-on-executable-files-in-the-terminal-or-iterm2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!