Some notes from finally learning PowerShell
I have to use Windows at my day job, and that means a lack of familiar unix tools. I’ve finally stopped putting off actually learning PowerShell properly. Here are some notes for my future self.
Autocomplete doesn’t have to suck
I am boggled why the default tab completion in Windows shells insists on being the terrible full completion of first match. Unlike cmd
, PowerShell doesn’t have to suck.
The built in command
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
switches to using a bash/zsh/fish style menu completion.
Place it in a profile script to run on shell launch.
Documentation seemingly isn’t installed by default
Powershell’s commands, cmdlets, and functions support a lot of declarative self documentation via argument definitions etc. Itʻs easy to be unaware that full human authored documentation also exists. help help
will tell you in a remark at the very bottom of the page that is easy to miss.
Curiously, if you use the full command Get-Help -Name Get-Help
rather than the aliases help
or man
, you are prompted immediately on first run to download the documentation.
Full documentation can be installed (or updated) with
Update-Help
Still need to figure out how to stop it yelling about missing resources.
Many things are exposed as “drives”
Environment variables, script variables, aliases, registry keys, and more, are available as labelled drives. You can list them like you would any other drive in Windows.
The alias:
drive is particularly useful for learning interactive commands, as it lists short abbreviations useful for interactive work, making it easier to overcome the verbosity of PowerShell when working interactively, as per unix.
Common unix (and cmd) commands are aliased to PowerShell cmdlets
man
, or ls
for example are both usable in PowerShell, but because they alias PowerShell commands rather than being their unix equivalents, things can get confusing.