Search code examples
shellunixfish

File extension coloring in fish shell


Is there a way to color code specific file extensions in the fish shell?

For example, if I ran the following command, I would want python files to appear a certain color and javascript files to appear a different color:

$ ls

file.py  # this would display as green for example
file.js  # this would display as yellow

I've been able to fully customize just about everything else but I can't figure out if there is a way to do this.


Solution

  • That isn't done by fish. It's done by the ls command. See the description of the LSCOLORS env var in man ls. I'm not aware of any ls implementation that allows you to customize the color based on the file extension. There may be third-party tools that you can pipe the output of ls through that will do what you want but I can't think of one off the top of my head.