Home > Uncategorized > Setting ls to reasonable colors in cygwin

Setting ls to reasonable colors in cygwin

April 15th, 2009

I often navigate folders in Windows explorer without using the mouse. This is quick, as you can jump to any file or folder by typing the first letters of the name and use backspace to go up one level. The speed is probably faster than what you achieve in a bash shell, where you complete names with tab.

In the Windows explorer, folders are listed first and have a yellow icon, files are just plain black-on-white. Using the bash shell in cygwin, I wanted to retain these mnemonic features.

Here is what goes into my .bashrc to achieve this:

alias ls='ls -A --color=auto --group-directories-first'
alias ll='ls -lh'
export LS_COLORS

A few words of explanation. It defines two aliases, one shadowing the ls command itself to 1) hide the . and .. folders in each output using the -A option 2) use coloring on device which support it only with the --color=auto 3) have folders listed first with the --group-directories-first. The second alias is really just a shortcut (using the first!) long listed dirs (with human readable file sizes).

The colors are basically bright-yellow (33;01) for all dirs, red (31) for executable files and default (00) for all other files and text. Note that it doesn’t really make sense to define a color for executable files in cygwin, as all existing files are executable per default.

Uncategorized , , ,

  1. Matt
    January 27th, 2011 at 10:24 | #1

    Thanks for this tip. I’ve been fighting with dircolors in cygwin without any luck. By manually setting the LS_COLORS in my .bashrc file I was finally able to get the colors I’ve always wanted

  2. kolcebruevsky
    August 19th, 2011 at 05:05 | #2

    Thank you for post! I have been problems with colors as Matt. I trying solve it a lot of time with DIR_COLORS and .bashrc. But your way is helped.

  1. No trackbacks yet.