Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

share|improve this question
This may be of some relevance… – Rook Oct 14 '09 at 16:52
up vote 6 down vote accepted
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:

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

share|improve this answer
Um... how do I get this to work permanently with all instances of cmd.exe? – aviraldg Oct 14 '09 at 17:24
That's what the .config file is for. HKEY_CURRENT_USER\Software\Microsoft\Command Processor\Autorun (make it if it doesn't exist), and point that towards a .bat. This means you can very easily configure ANY variable without actually making any changes that aren't very easy to reverse. Make sure to add an @ECHO OFF so it doesn't tell you what you're doing every time you start a prompt :) – Phoshi Oct 14 '09 at 17:29
Well, it does what it should, but it silently chops off all other arguments to ls – aviraldg Oct 14 '09 at 17:39
aaaand this is why I use a python script. Append a $* (means "all arguments", like %* in a batch file), and sorry for missing it out! – Phoshi Oct 14 '09 at 18:16

Instead of typing ls --color, you could define a bash alias:

alias ls='ls --color'

This would produce ls --color each time you write ls.

share|improve this answer
Says alias is not recognized as an internal or external command,.. you know the rest. – Qwerty Jun 14 at 13:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.