[英]Sh alias equivalent of PowerShell Set-Alias
Sh 中的這個 PowerShell 代碼相當於什么:
Set-Alias -Name PS7 -Value "C:\\Program Files\\PowerShell\\7\\pwsh.exe"
PS7 {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}
我嘗試了以下內容:
alias ps="C:/Program Files/PowerShell/7/pwsh.exe"
ps {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}
但這似乎不起作用。 有可能嗎? 我希望它是內聯的,而不是在腳本中。
假設你在WSL
中:
alias ps=\"$(wslpath -u 'D:\Program Files\PowerShell\7\pwsh.exe')\"
alias ps
alias ps='"/mnt/d/Program Files/PowerShell/7/pwsh.exe"'
ps -nopro -c '& {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}'
Name Value ---- ----- PSVersion 7.0.3 PSEdition Core GitCommitId 7.0.3 OS Microsoft Windows 10.0.19041 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 1 2 3 4 5
僅供參考,我在下面(從cmd
運行): ver & wsl --list
Microsoft Windows [Version 10.0.19041.508]
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
Ubuntu-18.04
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.