TIL: Editing commands from bash history before execution
After years of copy-pasting from `history | grep`, I just learned:
fc 945
→ Opens command #945 in $EDITOR
→ Edit as needed
→ Auto-executes on save
Quick alternative:
!945:p (print command)
↑ (recall and edit)
Or for lighter editor:
fc -e - 945
The fc approach is perfect for complex multi-line edits. The !945:p method is faster for single-parameter changes since you stay in the shell.
