You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在macOS安装PowerShell及将其集成至系统终端?

How to Integrate PowerShell with macOS Terminal After PKG Installation

Hey there! I get that you've already installed PowerShell using the PKG installer and can launch it from your Applications folder, but want the convenience of accessing it directly from your macOS terminal. Let's walk through how to fix this—chances are it's just a quick path setup or command clarification issue.

First, let's clear up a common confusion: on macOS, the official command to launch PowerShell after PKG installation is pwsh, not powershell. That's probably why you weren't seeing the expected behavior when trying the latter!

Here's the step-by-step fix:

1. Verify the PowerShell executable path

First, confirm the location of the PowerShell binary inside the app bundle. Open your terminal and run:

ls /Applications/PowerShell.app/Contents/MacOS/pwsh

If you see the file listed, you're good to go. If not, double-check that the PowerShell app is actually in your Applications folder.

The easiest way to make pwsh available from any terminal window is to create a symbolic link from the app's binary to a directory that's already in your system's PATH (like /usr/local/bin, which is standard for user-installed tools).

Run this command in your terminal (you'll need to enter your admin password when prompted):

sudo ln -s /Applications/PowerShell.app/Contents/MacOS/pwsh /usr/local/bin/pwsh

If you get an error saying /usr/local/bin doesn't exist, create it first with:

sudo mkdir -p /usr/local/bin

Then re-run the symbolic link command.

3. Test it out

Close your terminal window and open a new one. Now just type:

pwsh

You should see the PowerShell prompt (usually starting with PS) pop up, meaning you're now in the PowerShell environment directly from your macOS terminal!

Troubleshooting if it still doesn't work

  • Check if /usr/local/bin is in your PATH by running echo $PATH. If you don't see it listed, you'll need to add it to your shell's configuration file:
    • For Zsh (default on newer macOS versions): Open ~/.zshrc in a text editor and add this line:
      export PATH="/usr/local/bin:$PATH"
      
      Save the file, then run source ~/.zshrc to apply the changes immediately.
    • For Bash: Edit ~/.bash_profile or ~/.bashrc instead, using the same export PATH line, then source the file.

That's all there is to it—you can now switch between macOS terminal and PowerShell with just the pwsh command, no need to navigate to the Applications folder anymore!

内容的提问来源于stack exchange,提问作者SuicideSheep

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:08:41