Thursday, January 24, 2008

"Dir/ls" mixup. How to get the Linux/Unix "ls" into windows DOS.

After working a couple of months with AIX, it became a habit to type in "ls" to list the content of folders.
The problem was that I took this command with me over to the Command Prompt in Windows as well. In windows, "dir" is the equivalent to "ls".

I earlier versions of Windows, you could solve this by typing in the command
doskey ls=dir
in a DOS prompt.
After that was don, you can type in "ls" and a "dir" would be executed.

But this doskey dissapears as soon as you close the Command Prompt window, and the next time you need it, you have to type in the doskey command once again.

There are 2 solutions for persistent doskey commands:

Method 1:
Change the shortcut for your Commapnd Prompt like this:

Where you put in "/k doskey ls=dir" at the end of the "target" field.

Method 2:
If you don´t start up the Command Prompt with a shortcut, but rather use the keyboard combination "Windows + R" and type in "cmd" and press enter, here´s the solution:

Changes in the registry (start - run - regedit).
Go to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor"
Insert the following value in the "Autorun" string:
  • doskey ls=dir

Presto, no matter how you start up the Command Prompt, the "ls" command will work.

Use method #2, cause if you don´t, the "TAB" button will not work in the Command Prompt to autocomplete the names of files and folders.

No comments: