How to create ls in windows command prompt?

前端 未结 19 2312
一向
一向 2020-12-07 08:34

I want to use ls in windows command prompt and make it run the dir command.

How can I do that?

19条回答
  •  感动是毒
    2020-12-07 09:31

    I recommend the following recipe.

    1. Use DOSKEY and $* to create your ls command.
    2. Make the command persistent by recording it in a .bat/.cmd file and add the path of the file to registry.

    For example, your command may look like
    DOSKEY ls=dir
    DOSKEY sublime="C:\Program Files\Sublime Text 2\sublime_text" $*
    $* is useful for commands that take on arguments. For example, here I like to be able to do sublime my_code.c.

    The registry for cmd is at HKEY_CURRENT_USER -> Software -> Microsoft -> Command Processor. Create a string valued entry called AutoRun with the full path of the file (not the containing folder) such as %USERPROFILE%\custom_command.cmd. Then each time cmd is run, your command will be loaded!

    You can add more useful stuffs to the batch file too. See here for an example template.

提交回复
热议问题