Working Fast

The keystrokes, predictions and chaining that make experienced people look fast.

Updated

Keystrokes

  1. Keyboard Shortcuts at the Prompt (Apprentice): Home and End jump to either end of the command line, Ctrl+Left and Ctrl+Right move a word at a time, Ctrl+Backspace deletes a word, Ctrl+Z undoes an edit, Esc clears the line, and Ctrl+Space shows every choice that fits where you're typing.
  2. Predictions and History, Fully Used (Journeyman): Set-PSReadLineOption makes the prediction list your standard view and lets PSReadLine remember 10000 commands instead of 4096, # and Tab bring back a command from this window by a word or its number, and Select-String finds every match in the saved history file at once.

Chaining

  1. Did It Work? `$?`, `$LASTEXITCODE`, `&&` and `||` (Apprentice): $? says whether the last command worked, $LASTEXITCODE holds the number a program ended with (0 when it worked), && runs the next command only if the last one worked, and || runs it only if the last one failed.

Exercise: Fewer Keystrokes

  1. Exercise: Fewer Keystrokes (Journeyman): Finish Grandma's photo book the fast way, setting PSReadLine up with a list view and a longer memory, fixing a long command with keys, finding an old command in a saved history, and writing one-line commands with && and || that a Pester check runs where the first step works and where it fails.