我如何问PowerShell的东西在哪里?
例如,"which notepad",它根据当前路径返回notepad.exe运行的目录。
我如何问PowerShell的东西在哪里?
例如,"which notepad",它根据当前路径返回notepad.exe运行的目录。
当前回答
如果你有勺子,你可以安装一个直接克隆:
scoop install which
which notepad
其他回答
当我开始在PowerShell中定制我的个人资料时,我做的第一个别名是“which”。
New-Alias which get-command
要将此添加到您的配置文件中,请键入以下内容:
"`nNew-Alias which get-command" | add-content $profile
最后一行开头的' n是为了确保它将作为一个新行开始。
There also always the option of using which. there are actually three ways to access which from Windows powershell, the first (not necessarily the best) wsl -e which command (this requires installation of windows subsystem for Linux and a running distro). B. gnuwin32 which is a port of several gnu binaries in .exe format as standle alone bundled lanunchers option three, install msys2 (cross compiler platform) if you go where it installed in /usr/bin you'll find many many gnu utils that are more up-to-date. most of them work as stand alone exe and can be copied from the bin folder to your home drive somewhere amd added to your PATH.
我对Which函数的命题是:
function which($cmd) { get-command $cmd | % { $_.Path } }
PS C:\> which devcon
C:\local\code\bin\devcon.exe
如果你有勺子,你可以安装一个直接克隆:
scoop install which
which notepad
我喜欢Get-Command |格式列表,或更短,使用别名的两个,只用于powershell.exe:
gcm powershell | fl
你可以找到这样的别名:
alias -definition Format-List
制表符补全使用gcm。
一次列出所有选项:
set-psreadlineoption -editmode emacs