Failing Productively

Cycling through command arguments with PowerShell

With the holiday season behind us, I’m sure we’re all sick of navigating arguments. However, I couldn’t resist sharing this neat PowerShell trick I learnt at the end of last year.

PowerShell uses PSReadLine to handle keyboard input. One excellent feature of PSReadLine is the SelectCommandArgument key handler. This selects the next argument on the command line and by default is bound to Alt+A.

I’ve never seen anything like this implemented in another shell (e.g. via GNU Readline or Reedline), but it’s super useful when running several long – but similar – commands in a row.

Here’s a quick example of SelectCommandArgument in action.

#Powershell