Home » Questions » Computers [ Ask a new question ]

How to change the default --color preference for "ls' on Windows?

How to change the default --color preference for "ls' on Windows?

I'm using ls (from Msys) on Windows. By default, ls doesn't colour-code directories and archives, but that's something I want. I'm tired of typing "ls -C" and "ls --color". Is there any way apart from setting up a bash script that will let me do this. (Remember, I'm on Windows)

Asked by: Guest | Views: 144
Total answers/comments: 1
bert [Entry]

"doskey ls=ls --color $*

doskey is built-in, even!

I have a startup .bat file that acts as sort-of a .bashrc, and throw all my aliases in there, as well as having a small Python script to manage them more easily. cmd is really very bearable with a few additional tools (Cygwin goes a long way, just add its \bin to your PATH)

To apply aliases automatically with each new instance of cmd, create a .bat file, for example at %USERPROFILE%\aliases.bat with this content:

@ECHO OFF
doskey ls=ls --color $*

Then, using regedit, locate HKEY_CURRENT_USER\Software\Microsoft\Command Processor\
and add a String Value named Autorun, with Value data set to: %USERPROFILE%\aliases.bat"