Search code examples
fish

How do I change the colour of directory listings with oh-my-fish?


I've recently decided to give the fish shell a shot and also started using oh-my-fish. The problem I'm having is that I can't figure out how to change the color of directory listings when running a command such as ls. The picture attached below shows directories being listed in a dark blue and files listed in a gray.

enter image description here

I've tried changing the theme to no avail and I can't figure out where else to look. Any ideas?


Solution

  • You are probably seeing the result of LSCOLORS, which you can look up in the ls man page or Google.

    The reason that you see this with fish and not, say, bash, is that fish wraps ls in a function that passes the -G flag, as you can see:

    > functions ls
    function ls --description 'List contents of directory'
        command ls -G $argv
    end
    

    You can change LSCOLORS to be something else, e.g. on OS X:

    set -Ux LSCOLORS gxfxbEaEBxxEhEhBaDaCaD
    

    That makes a universal environment variable, so you just have to run it once.

    Or you can disable it entirely by overwriting the function:

    function ls ; command ls ; end
    funcsave ls
    

    This creates and saves a function ls that has priority over the bundled one.