跳转至

PowerShell配置新的alias

本文信息

创建时间: 2022.03.20 15:52:11

更新时间: 2023.08.16 22:34:42

问题

Windows的powershell没有 ll 命令,但 ls 的效果与Linux的 ls -la 效果基本一致

PowerShell
ll: The term 'll' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

解决方法

查看现有的命令

PowerShell
$Alias:ll
输出为空,表明当前环境不能识别此命令

临时使用

创建新的alias

PowerShell
Set-Alias ll ls
等价于
Text Only
Set-Alias -Name ll -Value ls

再次键入 ll
image.png

永久使用

写入到powershell的启动文件即可

PowerShell
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE
将新的alias命令加入到此文件即可 ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
PowerShell
# setup alias
Set-Alias ll ls

参考