场景:
Linux的alias命令是个非常实用的工具,任何命令通过alias可以精简到很短,比如:alias l='ls -l'
Windows也有alias类似的命令,就是:doskey,开启方法也很简单
环境:win7 + 64 bit
1. C:Users[用户名]alias_key.bat
@doskey ls=dir /b $*
@doskey l=dir /od/p/q/tw $*
@REM notepad++工具设置别名为:npp
@doskey npp="C:Program Files1Notepad++
otepad++.exe" $*
@doskey p=python $*
@doskey py=python $*
- 等号左边是右边的别名
- $*表示这个命令还可能有其他参数
- @表示执行这条命令时不显示这条命令本身
2. alias_key.reg
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor]
"AutoRun"="%USERPROFILE%\alias_key.bat"
双击上述 aliaskey.reg 文件,导入到注册表!
3. 打开cmd,然后运行:ls 或 npp 命令,看看效果
参考:
https://superuser.com/questions/49170/create-an-alias-in-windows-xp Create an alias in Windows XP
https://www.awaimai.com/2445.html
http://www.cnblogs.com/fstang/archive/2013/04/06/3002006.html
延伸:
%USERPROFILE% =C:Users用户名
%SystemRoot% =C:WINDOWS
%SystemDrive% =C:
%APPDATA% =C:Users用户名AppDataRoaming
%LOCALAPPDATA% =C:Users用户名AppDataLocal
%windir% =C:WINDOWS
%Path% =C:Windowssystem32;C:Windows;
%ProgramData% =C:ProgramData
%ProgramFiles% =C:Program Files
%ProgramFiles(x86)% =C:Program Files (x86)
其他:
%ALLUSERSPROFILE% =C:ProgramData
%CommonProgramFiles% =C:Program FilesCommon Files
%CommonProgramFiles(x86)% =C:Program Files (x86)Common Files
%CommonProgramW6432% =C:Program FilesCommon Files
%COMPUTERNAME% =MyPC
%ComSpec% =C:WINDOWSsystem32cmd.exe
%HOMEDRIVE% =C:
%HOMEPATH% =Users用户名
%LOGONSERVER% =\MicrosoftAccount
%OS% =Windows_NT
%ProgramW6432% =C:Program Files
%PUBLIC% =C:UsersPublic
%TEMP% =C:Users用户名AppDataLocalTemp
%TMP% =C:Users用户名AppDataLocalTemp
%USERDOMAIN% =MyPC
%USERNAME% =用户名