Happy use of alias in cmd

cmdsettings on windowsalias

Recently , I pnpmfeel that the input p,n,p,mis not very accustomed to using it. So I set it up on my own windows.alias

MicrosoftThe documents you consulted can be found doskey, and you can use doskeythem to create common ones alias.

bat file

First create a new .batfile and write the required settings alias.

starts doskeywith , then is alias, followed by the actual command after the equals sign.


@REM  $* 表示这个命令可能会有参数
@REM  @doskey表示执行这个命令时,不显示这条命令本身

@REM pnpm相关

@doskey ls=dir /b $*
@doskey p=pnpm 
复制代码

Add this bat file in the registry

win + RThen enter regeditinto the registry, follow HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRunthis path to find

If you don't have AutoRunthis option, you can right-click Command Processorand then create new --> string value --> input AutoRun. Then right-click to modify the new one . Enter the path AutoRunof the previously created file in the value data ..bat

Mine is to put the batfile in the user directory. Then use the system variable directly %USERPROFILE%\fastkey.bat.

alias.png

If you feel that opening the registry is too troublesome, there is another way.

Create REG file

For example, create a file alias.regand enter the following.

AutoRunThe value is .batthe path to the file.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"AutoRun"="%USERPROFILE%\fastkey.bat"
复制代码

Then double-click to run the REGfile and it will be automatically added to the registry.

Finally open cmd to verify

Enter lsthe command. You will see dirthe same effect as.

Guess you like

Origin juejin.im/post/7082688502340517896