How to create ls in windows command prompt?

前端 未结 19 2267
一向
一向 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:09

    You could:

    • create a batch file called ls.bat and have it contain the dir command only
    • add the directory where the ls.bat file exists to your PATH environment variable

    You could then execute ls from a command prompt.

    0 讨论(0)
  • 2020-12-07 09:12

    If you just want to have cmd recognize ls as an alias for dir, you can use the doskey command (from this answer on superuser).

    This does not change the original command line parameter handling of the dir command.

    0 讨论(0)
  • 2020-12-07 09:14

    You can solve this question with one simple command:

    echo @dir %* > %systemroot%\system32\ls.bat
    

    Make sure you run cmd.exe as admin first if you are on vista and up

    0 讨论(0)
  • 2020-12-07 09:17

    Easiest way I have found is:

    1. Install Git for Windows
    2. Add the bin directory of Git to your Path variable. Mine was located in C:\Program Files\Git\usr\bin.
    3. Start a command prompt and enjoy ls in all its glory.
    0 讨论(0)
  • 2020-12-07 09:17

    you could also use cygwin and just use the ls command directly along with all the other unix command line tools you might be used to.

    0 讨论(0)
  • 2020-12-07 09:19

    If you have Node.js installed on your system, you can install it from Cash, a library I wrote for Linux commands on Windows:

    npm install cash-ls -g
    
    0 讨论(0)
提交回复
热议问题