OK, I’m an idiot and did not realize the big transitions happening with PowerShell, it explains why a bunch of the Google commands don’t work like Remove-Service. The short story is that Powershell v5 is kept for compatibility reasons, but Microsoft has moved on to Powershell Core which is a cross-platform version that is Powershell v7. You access the former with powershell.exe
and the other with pwsh.exe
with a host of compatibility issues.
How confusing is that, so when you are writing a PowerShell script, you need to know the version number. More fun, but you can figure out what version you are running with (Get-Host).Version.
One reason, to do this is that there are newer commands like Remove-Service
which are only in Powershell-Core (aka Powershell 6 and beyond).
The second note is that Windows Terminal apparently automatically figures out what shells you have. This is called dynamic profiles so basically when you start windowsterminal.exe
you will automagically see in the down arrow all the shells that you can see. Pretty neat.
And you can easily exec PowerShell Core from WSL2 with pwsh.exe -Command sudo choco install _command_
which will invoke the new power shell, run the sudo script to get you into an administrative mode, and then you can run Choco.
Windows Terminal like iTerm on the Mac has got many useful keyboard shortcuts, so here are some. They are not super discoverable, so you have to use the internet to figure it out and they also pave over some commands like CTRl-SHIFT-^ that vi uses to switch between files:
- Ctrl-Shift-F to find in the window
- Ctrl-Shift-Space gets you a list of shells and the short cuts Ctrl-Shift-1 through 9 give you fast opening.
- Ctrl-, to get you the config JSON file
- Alt-Enter to go fullscreen
- Ctrl-Shift-D to Duplicate a tab
- Ctrl-Tab for next tab
- Ctrl-Shift-Tab for previous tab
- Ctrl-alt-1 through 9 to to to a specific tab
- Ctrl-Shift-n to get a new window
- Alt-Shift-d to duplicate a pane with the active shell
- Alt-Shift-Minus split horizontally and start the default shell (not usually what you want)
- Ctrl-Shift-w to close a pane
- Alt-up, left, right and down to move to a new pane
- Ctrl-Equal for a bigger font
- Ctrl-Minus for a smaller font
- Ctrl-0 to reset to default font
As an aside on Windows, none of the create new window commands seem to work like (ctrl-shift-n) and yes the irony is not lost on me 🙂