For the better part of the year I have been having some issues with Windows Terminal that in combination with Powershell (pwsh) which has bothered me quite a lot. It is quite specific issue since it seems occurs when only when Powershell Core is installed via scoop.

The issue

The issue happens when you want to abort/close a running application/script by pressing Ctrl-C. This causes the whole powershell-terminal to exit, leaving me with a non-working terminal. Example:

❯ ping google.com

Pinging google.com [216.58.211.142] with 32 bytes of data:
Reply from 216.58.211.142: bytes=32 time=64ms TTL=114

Ping statistics for 216.58.211.142:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 64ms, Maximum = 64ms, Average = 64ms
Control-C

[process exited with code 3221225786]

This is really frustrating because then you have to have to open a new terminal tab to continue to work and all extra work that comes with that.

Workaround/solution

Couple of days ago I finally found why this is happening and a workaround/solution for the problem in a comment for this issue on the powershells github-page.

The problem seems to be that scoop installs shortcuts for all applications as Shims, see this github page for more information. I.e. a small applications that executes another application based on configuration.

And when you press Ctrl-C in windows-terminal you exit the shim-application and not the powershell application and that’s why the whole process is shutdown.

The workaround is to change the settings in windows-terminal for pwsh by adding the path directly to pwsh.exe instead of it using the shim pwsh.exe:

    "commandline": "%USERPROFILE%\\scoop\\apps\\pwsh\\current\\pwsh.exe"

The whole powershell core block in my Windows Terminal settings.

Before:

{
    "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
    "hidden": false,
    "name": "PowerShell",
    "source": "Windows.Terminal.PowershellCore"
}

After:

{
    "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
    "hidden": false,
    "name": "PowerShell",
    "source": "Windows.Terminal.PowershellCore",
    "commandline": "%USERPROFILE%\\scoop\\apps\\pwsh\\current\\pwsh.exe"
}

Now Ctrl-C works just fine.

❯ ping google.com

Pinging google.com [216.58.215.110] with 32 bytes of data:
Reply from 216.58.215.110: bytes=32 time=51ms TTL=115

Ping statistics for 216.58.215.110:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 51ms, Maximum = 51ms, Average = 51ms
Control-C

Yaay, no more closing down tabs and re-opening them again.