Ugh version nightmares with PowerShell and really using Windows Terminal

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:

  1. Ctrl-Shift-F to find in the window
  2. Ctrl-Shift-Space gets you a list of shells and the short cuts Ctrl-Shift-1 through 9 give you fast opening.
  3. Ctrl-, to get you the config JSON file
  4. Alt-Enter to go fullscreen
  5. Ctrl-Shift-D to Duplicate a tab
  6. Ctrl-Tab for next tab
  7. Ctrl-Shift-Tab for previous tab
  8. Ctrl-alt-1 through 9 to to to a specific tab
  9. Ctrl-Shift-n to get a new window
  10. Alt-Shift-d to duplicate a pane with the active shell
  11. Alt-Shift-Minus split horizontally and start the default shell (not usually what you want)
  12. Ctrl-Shift-w to close a pane
  13. Alt-up, left, right and down to move to a new pane
  14. Ctrl-Equal for a bigger font
  15. Ctrl-Minus for a smaller font
  16. 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 🙂

I’m Rich & Co.

Welcome to Tongfamily, our cozy corner of the internet dedicated to all things technology and interesting. Here, we invite you to join us on a journey of tips, tricks, and traps. Let’s get geeky!

Let’s connect