如何更新 Cmder 以使用 PowerShell Core?

如何更新 Cmder 以使用 PowerShell Core?

PowerShell Core 6.0.0发布 我想开始使用它来代替 Windows 10 的默认 PowerShell。

我目前使用基于 ConEmu 的 Cmder 来实现这一点。已经有两个 PowerShell 任务,我假设我可以更新它们以指向我本地安装的 PowerShell Core(在 C:\Program Files\PowerShell\6.0.0 中)。

我已尝试将 Powershell::Powershell 的任务参数更新为以下内容:

/dir "C:\Program Files\PowerShell\6.0.0\" /icon "%CMDER_ROOT%\icons\cmder_blue.ico"

然后我将命令更新如下:

"%ProgramFiles%\PowerShell\6.0.0\PowerShell.exe" -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''" -new_console:d:"%USERPROFILE%" -new_console:d:D:\git

但是,它因以下错误而中断:

‘c:\program’ 不是内部或外部命令,也不是可运行的程序或批处理文件。

我该如何设置 Cmder/ConEmu 来调用 PowerShell Core 版本的 PowerShell 而不是默认安装?

答案1

使用

*pwsh -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''"

在此处输入图片描述

答案2

我目前使用基于 ConEmu 的 Cmder 来实现这一点。已经有两个 PowerShell 任务,我假设我可以更新它们以指向我本地安装的 PowerShell Core(在 C:\Program Files\PowerShell\6.0.0 中)。

您使用了错误的可执行文件。

PowerShell Core 的二进制名称已从 powershell(.exe) 更改为 pwsh(.exe)。此更改为用户提供了一种在计算机上运行 PowerShell Core 的确定性方法,以支持并行安装 Windows PowerShell 和 PowerShell Core。pwsh 也更短且更易于输入。

PowerShell Core 6.0 中的新增功能

此外

您可以通过“开始”菜单或 $env:ProgramFiles\PowerShell\pwsh.exe 启动 PowerShell

在 Windows 上安装 PowerShell Core

答案3

安装 powershell 7/Core 后,您可以使用 ConEmu 功能添加/刷新默认任务为 pwsh 添加额外任务。从文档

如果您安装了新应用程序(例如新版 Visual Studio)或新版 ConEmu,且该版本比以前的版本了解更多预定义 shell,则 ConEmu 不会在没有用户请求的情况下自动创建新任务。

如果您想添加错过的任务,或使用默认(推荐)参数重新创建现有任务,只需打开“任务”设置页面并按“添加/重新创建默认任务…”按钮。ConEmu 将确认操作(“是”- 添加错过的任务;“否”- 使用默认值重写现有任务),您将在任务列表末尾获得新任务!

请注意,在 cmder 中,按钮实际上被标记为添加/刷新默认任务...在里面设置任务对话。

相关内容